How kill executables started with spawnShell or executeShell when program finish?
Dukc
ajieskola at gmail.com
Tue Oct 27 22:14:53 UTC 2020
On Tuesday, 27 October 2020 at 15:16:33 UTC, Marcone wrote:
> Becouse my program use plink.exe running with spawnShell or
> executeShell.
> But when my program finish with some crash, or killed with
> windows task manager by user, Plink still running. How can I
> stop all process initialized with spawnShell or executeShell
> when program finish? I another works, how can I make plink.exe
> only lives when program is running?
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.
More information about the Digitalmars-d-learn
mailing list