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 15:12:57 -0600
User-agent: KMail/1.9.1

Andreas:

Thanks.  I've been experimenting with this and making some progress.  In 
summary, I've found:

1) since the background job is started by one non-interactive script, and 
killed by another non-interactive script, job control does not enter into the 
solution.

2) The second "killing" script needs to perform an incantation of
        ps -ajx | awk "some awk expression"
to discover the process group of the backgrounded job, then
/bin/kill -s SIGTERM -pgrpid

the target pgrpid.  (/bin/kill is required.  The bash builtin kill cannot kill 
an entire process group.)

If the process group of the background job could be returned or queried when 
the background job is launched, I could save this, in say, /var/run, and make 
it much easier for the second "killing" script to discover the target process 
group.  I don't see a direct bash mechanism for doing this.

However, it looks like bash currently puts all backgrounded processes into a 
pgrp set from the pid of the parent shell.  Thus, I could save the pid of the 
parent shell in /var/run.  I don't know if I can depend upon this behavior in 
future releases.

Please let me know if I am misunderstanding, and thanks for your help.

        Jeff

On Tuesday 06 March 2007 14:25, Andreas Schwab wrote:
> Jeff Weber <address@hidden> writes:
> > enable job control,
>
> $ set -m
>
> > and kill the entire backgrounded job from a second
> > non-interactive script?
>
> You send the signal to the process group.
>
> Andreas.

-- 
Jeff Weber
American Superconductor Corp.




reply via email to

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