Op 7/19/2020 om 5:40 PM schreef Bo Berglund via fpc-pascal:
On Sun, 19 Jul 2020 08:46:14 +0200 (CEST), Michael Van Canneyt
<mich...@freepascal.org> wrote:

Various RunCommand procedures in process unit:
https://www.freepascal.org/docs-html/current/fcl/process/runcommand.html

But it looks like it hangs around until the started process exits...
How can I set a timeout on the execution (don't want the whole system
to hang if this external program does not exit)?

Runcommand handles the most used scenarios only. But in FPC 3.2.0 there have been some changes to make own variants easier.

I happened to make a variant with a timeout last week, and use this as a demonstration for that (3.2.0+) functionality :

https://forum.lazarus.freepascal.org/index.php/topic,50525.msg368880.html#msg368880

but that is as of yet still untested on non-windows. (but it is general in principle)



I'll answer these because they are not documented yet:

poRunIdle -  mainly for tprocess.runcommandloop:  run a sleep() in the main loop that polls the pipes.

                      In general, enable it for runcommands that run longer (to reduce CPU use), disable it if you expect that the process runs very short (e.g. "hostname"  on linux)

poDetached - The Windows implementation of poNoconsole of FPC 3.0.4 and older.   FPC 3.2.0+ ponoconsole is instantiates less of the console, but this causes problems for a few programs (like mysql console). In those cases use podetached instead ponoconsole

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to