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.
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. Do I have that right? 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. :) 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. 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. On Wed, Nov 30, 2011 at 6:27 PM, Ole Tange <[email protected]> wrote: > In the following note the big difference between the option --timeout > and the command timeout. > > --timeout right now kills the job running. It does not kill off any > children started by the job: > > echo 'sleep 60; true' | parallel --timeout=3 > ps f -t $(tty) -o pid,pgid,args > [ ... the $SHELL started is killed, but the sleep 60 is still running ... ] > > A solution to that is using the command 'timeout': > > echo 'sleep 60; true' | parallel timeout 3 bash -c {} > ps f -t $(tty) -o pid,pgid,args > > A problem by that is that you have to install 'timeout' (on Debian it > is part of coreutils, so it might not be a big issue). > > Another problem is that suspend (CTRL-Z) will not suspend the children: > > parallel -q timeout 10 perl -e '$a=1;while($a<{}){$a++}' ::: > 1000000000 1000000001 > <CTRL-Z> > top > [ ... 2 perl processes take up 100% CPU ... ] > > Right now suspending works: > > parallel -q --timeout 10 perl -e '$a=1;while($a<{}){$a++}' ::: > 1000000000 1000000001 > <CTRL-Z> > top > [ ... 2 perl processes take up 0% CPU ... ] > > I do not see a way to implement both, so you should now vote: > > [ ] I prefer the current behaviour (CTRL-Z suspends children when > using --timeout) > [ ] I prefer --timeout kills off a job's children (CTRL-Z suspends > parallel, but not children when using --timeout) > > > /Ole >
