bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: signal propogation to backgrounded subshells


From: Jeff Weber
Subject: Re: signal propogation to backgrounded subshells
Date: Tue, 6 Mar 2007 13:59:14 -0600
User-agent: KMail/1.9.1

Andreas:

On Tuesday 06 March 2007 12:40, Andreas Schwab wrote:
> Jeff Weber <jweber@amsuper.com> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]