[fpc-pascal] TProcess questions

Adrian Maier adrian.maier at gmail.com
Tue Oct 3 10:39:45 CEST 2006


On 10/3/06, Michael Van Canneyt <michael at freepascal.org> wrote:
>
> On Tue, 3 Oct 2006, Adrian Maier wrote:
>
> > On 10/3/06, Michael Van Canneyt <michael at freepascal.org> wrote:
> > > > Any idea how should i quote the arguments so that they would be properly
> > > > treated by TProcess?
> > >
> > > You can't. The following lines (line 107 of unix/process.inc)
> > > Result:=StringReplace(Result,'"','',[rfReplaceAll]);
> > > Result:=StringReplace(Result,'''','',[rfReplaceAll]);
> > > Will strip all quotes inside a quoted string.
> > >
> > > Obviously, this is a bug.
> >
> > It's a painful one.  I was hoping to switch to TProcess instead of shell (
> > which isn't  cross-platform )  ...
>
> The bug won't occur on windows :)

> I will see about fixing it. Could you please post a bug report so it won't
> be forgotten.

Ok.

> > > > 3.  The code returned by the called program can be got with
> > > > TProcess.ExitCode , right ?   I have a situation in which a program  1
> > > > , but  TProcess.ExitCode is 0.   Therefore it's impossible to detect
> > > > the failure.
> > >
> > > That can be if the program exited because of a signal.
> >
> > I'm not sure if this was the case - I'll have to investigate.
> > Anyway, is it possible to detect this situation ?
>
> Well, first of all you should do a 'IsRunning' (or running) before checking
> the exitcode.

I'm using the poWaitOnExit  option,  so my program doesn't waits
until the external process ends.   All I need is to know if the
external process ended successfully or not .

> Only after that you can check the exit code. About the signalling,
> we'd need to extend TProcess for that.

I understand.


Cheers,
Adrian Maier



More information about the fpc-pascal mailing list