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: Andreas Schwab
Subject: Re: signal propogation to backgrounded subshells
Date: Tue, 06 Mar 2007 19:40:36 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

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.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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