Would this work? http://search.cpan.org/~sharyanto/Process-KillTree-0.02/lib/Process/KillTree.pm
On Fri, Dec 2, 2011 at 7:25 AM, Ole Tange <[email protected]> wrote: > On Thu, Dec 1, 2011 at 9:25 PM, Jay Hacker <[email protected]> wrote: >> So currently parallel runs all jobs in the same process group, and >> CTRL-Z suspends everything in the current terminal process group, >> which is a nice feature. > > Yep. > >> If you wanted to kill all descendants of a job, you'd have to put them >> in a separate process group, but this breaks CTRL-Z. So currently >> parallel only kills its immediate children. The timeout command (I'm >> guessing) puts things in a different process group (so it can kill its >> children), which prevents CTRL-Z from working. > > Yep. > >> Do I have that right? > > Yep. > >> Two ideas I can see exploring: >> >> 1. Walk the process tree and kill all descendents of all jobs. I >> don't know if there is a portable way to do this (surely CPAN has >> something? ;) >> >> 2. Have parallel kill its own process group, effectively committing >> mass family suicide. Hey, it's about to exit anyway. :) > > No good. The timeout is per job, so there may be others jobs in the queue. > >> This may be >> unpalatable because parallel needs to do some cleanup; perhaps >> parallel could install a SIGTERM handler, do its cleanup in there >> (which seems reasonable anyway), and then send the final SIGKILL to >> the process group. > > Currently parallel sends a TERM, waits 200 ms, sends another TERM, > waits another 200 ms, and finally sends a KILL. So if the child was a > respectful child it would propagate these signals to its children. But > alas, children are not well behaved these days. > >> If neither of those works, I'd prefer --timeout kills a jobs children; >> usually when using CTRL-Z I just want to get back to my terminal, and >> the first thing I type is 'bg' anyway, so suspending the children is >> not that big a deal. Also FWIW, RedHat 5 doesn't have a timeout >> command that I can find. > > Good to know. > > > /Ole
