[fpc-pascal] Redirecting input to a child process

Anton Shepelev anton.txt at gmail.com
Sun May 8 22:16:47 CEST 2011

waldo kitty:

> how  about  sending  the ^Z line the CRLF is being sent to
> indicate line breaks??

This I had tried even before posting the question :)

Ludo Brands:

> I don't see where you close the mProcess.input.

In my original post I call:


As  for  the program based on SteveG's code, I tried to keep
his code as intact as possible, so I didn't close the  input
handle in it.

> Pipes.pp  doesn't  have  any routines to clean up the pipe
> handles which is according to msdn not good.

You mean reading from the pipes after  the  closing  of  the
child process?

> According to msdn... the pipe handles  should  be  created
> non-inheritable in order to detect EOF.

Oh, I missed this. My WinApi program creates pipes with:

    SECURITY_ATTRIBUTES.bInheritHandle = true;

in  order  for  the  handles to be properly inherited in the
child process. That must be my problem. The only  other  way
to  do  it is to use the DuplicateHandle function which will
create in inherarable duplicate of the original handle, that
can then be passed to the CreateProcess. The original handle
will remain non-inheritable and should trigger EOF  on  clo-

Thank  you  for your investigation. I'll try duplicating the
handles and report the results.


More information about the fpc-pascal mailing list