<div dir="ltr">Hi Johannes:<div><br></div><div>I had a similar question a few years back using the async library and in particular the 'race' function. I got a nice answer on StackOverflow:</div><div><br></div><div>    <a href="https://stackoverflow.com/questions/24446154/control-concurrent-async-race-and-runinteractiveprocess">https://stackoverflow.com/questions/24446154/control-concurrent-async-race-and-runinteractiveprocess</a><br></div><div><br></div><div>I think you can use the ideas in there. Bottom line: You can use a combination of 'onException' and 'terminateProcess' and let your spawned processes clean-up after themselves properly.</div><div><br></div><div>Cheers,</div><div><br></div><div>-Levent.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 24, 2018 at 6:42 AM, Johannes Waldmann <span dir="ltr"><<a href="mailto:johannes.waldmann@htwk-leipzig.de" target="_blank">johannes.waldmann@htwk-leipzig.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Cafe,<br>
<br>
I am using<br>
<a href="https://hackage.haskell.org/package/process-1.6.4.0/docs/System-Process.html#v:readProcess" rel="noreferrer" target="_blank">https://hackage.haskell.org/<wbr>package/process-1.6.4.0/docs/<wbr>System-Process.html#v:<wbr>readProcess</a><br>
to start an external command, and wait for its completion.<br>
<br>
Now I would like to time-out this after a while.<br>
I can use<br>
<a href="https://hackage.haskell.org/package/base-4.11.1.0/docs/System-Timeout.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/<wbr>package/base-4.11.1.0/docs/<wbr>System-Timeout.html</a><br>
and this works in simple cases -<br>
<br>
but not in case the external command has spawned child processes.<br>
(cleanupProcess sends SIGTERM but only to the process at the top of<br>
the tree ?)<br>
<br>
I guess I need to use<br>
<a href="https://hackage.haskell.org/package/unix-2.7.2.2/docs/System-Posix-Process.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/<wbr>package/unix-2.7.2.2/docs/<wbr>System-Posix-Process.html</a><br>
but that seems rather low-level - and I don't see how I would<br>
get the ProcessID of the process started by  readProcess,<br>
so I'd also have to re-do that.<br>
<br>
Is there an abstraction/library that would help here?<br>
<br>
Thanks - J.W.<br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br></div>