[Haskell-cafe] how to terminate a (Posix) process and all its subprocesses?
allbery.b at gmail.com
Tue Jul 24 18:05:39 UTC 2018
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.
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.
On Tue, Jul 24, 2018 at 9:42 AM Johannes Waldmann <
johannes.waldmann at htwk-leipzig.de> wrote:
> Dear Cafe,
> I am using
> to start an external command, and wait for its completion.
> Now I would like to time-out this after a while.
> I can use
> and this works in simple cases -
> but not in case the external command has spawned child processes.
> (cleanupProcess sends SIGTERM but only to the process at the top of
> the tree ?)
> I guess I need to use
> but that seems rather low-level - and I don't see how I would
> get the ProcessID of the process started by readProcess,
> so I'd also have to re-do that.
> Is there an abstraction/library that would help here?
> Thanks - J.W.
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe