bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH] trap -p does not display ignored signals inherited from pare


From: Eric Blake
Subject: Re: [PATCH] trap -p does not display ignored signals inherited from parent by a bash process
Date: Thu, 25 Mar 2010 15:10:05 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b1 Thunderbird/3.0.3

On 03/25/2010 01:32 PM, Siddhesh Poyarekar wrote:
> In a terminal, execute a script which does basically this:
> 
> trap '' SIGTERM
> ...
> bash
> 
> According to the above explanation, the resultant bash prompt I get on
> execution of this script will allow me to override the ignored SIGTERM
> since it was set in its non-interactive parent.

No.  In that case, you ended up with an interactive shell, where POSIX
is silent on the expected behavior.  Or, put another way, by stating
nothing explicit about interactive shells, POSIX has implicitly stated
that the resulting bash prompt MAY, but not MUST, allow you to override
the ignored SIGTERM, and that you, as the interactive user, have no
guarantees on which behavior was chosen by bash.

On the other hand, change that last line to 'bash ./program', where
'./program' is a bash script, and then POSIX is clear that ./program
MUST be prohibited from changing SIGTERM because it is non-interactive
and inherited an ignored SIGTERM.

> So any signal that GETORIGSIG is called for and is inherited as
> ignored from parent will automatically be hard ignored.

Yes.  POSIX requires this for non-interactive shells, and does not
forbid it for interactive shells.  Technically, this code could be
modified to exempt interactive shells from hard-ignores, or left as is
by treating both classes of shells identically in keeping things
hard-ignored; either approach still meets POSIX.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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