How kill executables started with spawnShell or executeShell when program finish?
Jack
jckj33 at gmail.com
Tue Oct 27 22:30:52 UTC 2020
On Tuesday, 27 October 2020 at 22:14:53 UTC, Dukc wrote:
> On Tuesday, 27 October 2020 at 15:16:33 UTC, Marcone wrote:
>> [...]
>
> This is a bit heavyweight, but should be doable: have your
> primary process to start a watchdog process for itself. The
> watchdog continuosly sends messages to the primary process. If
> the message gets blocked or the watchdog receives no answer, it
> assumes the primary process has stopped working and thus
> terminates first plink.exe first and then itself.
>
> In fact, while you're on it you can make the watchdog to
> terminate the primary process too, so the user won't have to
> kill the program manually in case of infinite loop.
In case of windows, the OS can take care of this with the JOB
functions family:
https://docs.microsoft.com/en-us/windows/win32/api/jobapi2/nf-jobapi2-assignprocesstojobobject
More information about the Digitalmars-d-learn
mailing list