Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15513 > unrolled thread

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

Started byIsaac To <isaac.to@gmail.com>
First post2019-10-15 17:22 +0800
Last post2019-10-15 17:22 +0800
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Signal ignore flags unexpectedly reset after "trap ... EXIT" Isaac To <isaac.to@gmail.com> - 2019-10-15 17:22 +0800

#15513 — Signal ignore flags unexpectedly reset after "trap ... EXIT"

FromIsaac To <isaac.to@gmail.com>
Date2019-10-15 17:22 +0800
SubjectSignal ignore flags unexpectedly reset after "trap ... EXIT"
Message-ID<mailman.776.1571143362.9715.bug-bash@gnu.org>
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

Description:

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.

Repeat-By:

$ 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
hello
$

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.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web