[fpc-pascal] TProcess usage and reading program output

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Tue Feb 28 17:38:59 CET 2017


On 2017-02-28 16:28, Michael Van Canneyt wrote:
> poWaitOnExit should not be needed, as this will cause Execute to wait for process exit...
> 
> It seems likely that this will interfere with reading from output: when the
> output buffer is full, the executed process will block.

Ah. I've also been reading the docs and this FPC wiki page...

   http://wiki.freepascal.org/Executing_External_Programs

In the wiki they talked about a dead-lock when poWaitOnExit is used and
the output buffer is full. It seems that is exactly what I experienced.
I'll increase the buffer size I use to 2048 and remove the poWaitOnExit
and see how it goes. The "Reading large output" example also uses a
TMemoryStream instead of a string buffer like I do, but I think we
should have the same end result.


http://wiki.freepascal.org/Executing_External_Programs#Reading_large_output

If my code still doesn't work, I'll switch to using a TMemorySteam for
storing the output and retest.

Thanks for the extra pair of eyes.

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list