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   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to