[fpc-pascal] CrossPlatform problem, INFINITE not defined on Linux

Bo Berglund bo.berglund at gmail.com
Sun Jul 19 18:59:49 CEST 2020


On Sun, 19 Jul 2020 17:51:59 +0200 (CEST), Michael Van Canneyt
<michael at freepascal.org> wrote:

>
>
>On Sun, 19 Jul 2020, Bo Berglund via fpc-pascal wrote:
>
>> On Sun, 19 Jul 2020 08:46:14 +0200 (CEST), Michael Van Canneyt
>> <michael at 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)?
>>
>> And if I just want to start a process but not wait for it to exit?
>
>Use TProcess.
>
>https://www.freepascal.org/docs-html/current/fcl/process/tprocess.html
>
>do NOT specify poWaitOnExit in the options, and simply call Execute. 
>It will return at once.

To clarify:
If I do not specify [poWaitOnExit] to Execute, then it will return
immediately with the process running and I can check whenever I like
if it is still running using the Running() method.
This seems like I can do what I need.

Question:
---------
If I free the TProcess object will that terminate the running process
or just detatch from it?
The description for TProcess.Destroy seems to indicate this.

The reason I ask this much is that the use case here is a remotely
running monitoring system taking regular measurements and as an option
after each measurement an analysis program may be started to evaluate
if an alarm should be sent out.
Since the system will be unattended I have to make sure it won't hang
anywhere...


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list