[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trap output piped to another program gives incomplete results
From: |
Eric Blake |
Subject: |
Re: trap output piped to another program gives incomplete results |
Date: |
Wed, 31 Mar 2010 07:50:26 -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/30/2010 11:45 PM, Siddhesh Poyarekar wrote:
> Fix:
>
> I've not looked at how this can be fixed yet, but it looks
> like bash is forking for the trap builtin, which inherits the
> ignored signals, hence showing only them as active traps
> into the pipe. The other signals are not inherited and hence
> do not show up at all.
See also this Austin Group report:
http://austingroupbugs.net/view.php?id=53
which states this about running trap in a subshell:
Change
"When a subshell is entered, traps that are not being ignored are
set to the default actions."
to
"When a subshell is entered, traps that are not being ignored shall
be set to the default actions, except in the case of a command
substitution containing only a single trap command, when the traps
need not be altered. Implementations may check for this case
using only lexical analysis; for example if `trap` and $( trap -- )
do not alter the traps in the subshell, cases such as assigning
var=trap and then using $($var) may still alter them."
Change
"The trap command with no arguments shall write to standard output
a list of commands associated with each condition."
to
"The trap command with no operands shall write to standard output
a list of commands associated with each condition. If the command
is executed in a subshell, the implementation does not perform
the optional check described above for a command substitution
containing only a single trap command, and no trap commands with
operands have been executed since entry to the subshell, the list
shall contain the commands that were associated with each
condition immediately before the subshell environment was entered.
Otherwise, the list shall contain the commands currently
associated with each condition."
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature