<div dir="ltr">The trick here is to set the option that creates a process group (System.Process's config record has a field for this), then extract the process id of the parent and negate it to get a process group ID. A signal sent to that will go to the entire process group.<div><br></div><div>You can do this with System.Process as opposed to System.Posix.Process, but you need to go digging into internals to get the process ID IIRC.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 24, 2018 at 9:42 AM Johannes Waldmann <<a href="mailto:johannes.waldmann@htwk-leipzig.de">johannes.waldmann@htwk-leipzig.de</a>> wrote:<br></div><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/package/process-1.6.4.0/docs/System-Process.html#v: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/package/base-4.11.1.0/docs/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/package/unix-2.7.2.2/docs/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>
_______________________________________________<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-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>