Andreas: On Tuesday 06 March 2007 12:40, Andreas Schwab wrote: > Jeff Weber <[EMAIL PROTECTED]> writes: > > Here's some sample code: > > > > # create a backgrounded subshell to execute long-running processes > > #( sleep 300 && sleep 400 && sleep 500 )& # doesn't work, bummer > > $SHELL -c "sleep 300; sleep 400; sleep 500" & # doesn't work, bummer > > pid=$! > > echo background job $pid > > > > > > When I run this, it announces the background job pid, which I then kill. > > I've tried SIGHUP, SIGINT, SIGTERM. The backgrounded bash job terminates > > as expected. However, the active sleep job continues to execute, now > > being owned by init. Somehow, it "escaped". I want any active sleep job > > to die too. > > > > Is this a bug, feature, or misunderstanding? > > It's not a bug. You only kill a single process, no other processes are > affected. > > > Regardless, is there a simple solution to get the behavior I want? > > You need to enable job control and kill the whole job. I scanned the bash man page and O'Reilly book and this looks difficult to do for my config: the backgrounded job is forked from non-interactive script1, and needs to be killed by noninteractive script2. The job control machinery looks tailored for use within the same interactive shell.
If job control is the answer. How do I: enable job control, and kill the entire backgrounded job from a second non-interactive script? thanks, Jeff _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash