[Top][All Lists]

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

Signal ignore flags unexpectedly reset after "trap ... EXIT"

From: Isaac To
Subject: Signal ignore flags unexpectedly reset after "trap ... EXIT"
Date: Tue, 15 Oct 2019 17:22:39 +0800

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-LQgi2O/bash-5.0=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux superposition 5.0.0-25-generic #26-Ubuntu SMP Thu Aug 1
12:04:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release


When trying to write a program and start it in an initrc script, I observed
a strange behavior: if a subshell is started by a subshell of that script,
and the inner subshell runs "trap ... EXIT", it unsets the signal ignore
flag of other signals.  I'm not sure whether this should be called a bug,
or whether it is a problem caused by my own configuration.  Anyway here is
how I reproduce my problem.


$ cat t.sh
echo t $BASHPID
trap '' USR1
grep SigIgn /proc/$BASHPID/status
bash --rcfile t2.sh
$ cat t2.sh
echo t2 $BASHPID
grep SigIgn /proc/$BASHPID/status
    echo subshell $BASHPID
    grep SigIgn /proc/$BASHPID/status
        echo subsubshell $BASHPID
        grep SigIgn /proc/$BASHPID/status
        echo trap $BASHPID
        trap 'echo hello' EXIT
        grep SigIgn /proc/$BASHPID/status
$ ./t.sh
t 15141
SigIgn: 0000000000000204
t2 15143
SigIgn: 0000000000380004
subshell 15145
SigIgn: 0000000000000200
subsubshell 15147
SigIgn: 0000000000000200
trap 15147
SigIgn: 0000000000000000

Note that the final SigIgn flag is completely reset, which is what I won't
expect.  The same problem won't occur if --rcfile is not used in t.sh.  And
the problem also didn't show up in bash 4.4.

reply via email to

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