> Package: bash
> Version: 3.1dfsg-8
>
> http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
>
> If action is '-', the shell shall reset each condition
> to the default value.
>
> bash(1):
>
> If arg is absent (and there is a single sigspec) or -, each
> specified signal is reset to its original disposition (the value it
> had upon entrance to the shell).
>
> And indeed the manpage for bash describes the actual behaviour, not
> the correct behaviour:
>
> $ perl -e 'print STDERR "Signal handling for SIGPIPE:
> $SIG{PIPE}.\n";'
> Signal handling for SIGPIPE: .
> $ sh -c 'trap "" PIPE; exec "$@"' x perl -e 'print STDERR
> "Signal handling for SIGPIPE: $SIG{PIPE}.\n";'
> Signal handling for SIGPIPE: IGNORE.
> $ sh -c 'trap "" PIPE; exec "$@"' x sh -c 'trap - PIPE;
> exec "$@"' x perl -e 'print STDERR "Signal handling for SIGPIPE:
> $SIG{PIPE}.\n";'
> Signal handling for SIGPIPE: IGNORE.
> $
>
> If the bash behaviour is thought desirable for some reason (although I
> can't imagine why) then another mechanism needs to be provided for
> resetting signals to SIG_DFL, as currently this is not possible in
> bash.
The bash behavior is correct. There are only two signal dispositions
a process can inherit from its parent: SIG_IGN and SIG_DFL. Posix
says that `trap' can't modify the disposition of a signal whose
inherited value is SIG_IGN, and an inherited value of SIG_DFL covers
the rest. In either case, the signal winds up with the disposition
the shell inherited.
If you look a couple of paragraphs past the sentence you quoted from Posix,
you'll find:
Signals that were ignored on entry to a non-interactive shell cannot
be trapped or reset, although no error need be reported when
attempting to do so. An interactive shell may reset or catch signals
ignored on entry.
This covers what you're trying to do. (Bash treats non-interactive and
interactive shells identically in this regard.)
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]