On Wednesday, 7 March 2018 at 15:03:28 UTC, Marc wrote:
I do need to start (up to 4 a time) processes in parallel but
I'd like to get notified (similar to C#'s Process.Exited Event)
when the process exits. How can I do that in D?
You can use pipeShell and a control loop to check when the
ProcessPipes it returns is done.
import std.stdio, std.process, std.conv, std.random,
iota(0,4).each!(a => pp[a] = pipeShell("sleep " ~
while (pp.any!(a => !tryWait(a.pid).terminated))
You can wrap in a struct to hide the ugly bits.