Package: bash Version: 4.2+dfsg-1 Severity: normal Dear Bash Maintainer,
Bash seems to have a bug in which it cannot reset the signal handler (using 'trap') when already within a signal handler. Here is a sample script that demonstrates the problem: ---------------------------------------------------------------------- # # ackbar.sh: a test of layered trap handling in Bourne-ish shells. # In a working shell, this script should exit when ^C is hit twice. # trap maybeexit 2 maybeexit() { trap reallyexit 2 echo echo -n "Cancelling task $x" sleep 1 echo trap maybeexit 2 } reallyexit() { echo echo "Okay, really exiting..." exit 0 } echo "Hit ^C to cancel current task." echo "Hit ^C twice to exit." while :; do x=$((x+1)) echo "Now churning on long running task no. $x" sleep 1000 done ---------------------------------------------------------------------- When run in Bash this script does not exit when ^C is hit twice. The first ^C is caught correctly, but the second merely kills the "sleep" in the "maybeexit" signal handler and continues execution. (Note: Using the "trap -p" command before the sleep, one can see that Bash actually thinks it has updated the signal handler, even though it does not honor it.) In contrast, when this script is run in other POSIX shells (I've tested dash, ksh, mksh, pdksh, and zsh), the script runs correctly. In those shells, hitting ^C twice calls the "reallyexit" signal handler which exits the program. I admit that there is much deep magic surrounding "correct" interrupt handling in different shells, but I'm not inexperienced, and I'd be very surprised if this is by design. If so, then there is a bug in the documentation, as I have pored over it repeatedly and there is no mention of traps being inoperable until the handler has finished. --Ben -- System Information: Debian Release: jessie/sid APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'testing'), (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.9-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages bash depends on: ii base-files 7.2 ii dash 0.5.7-3 ii debianutils 4.3.4 ii libc6 2.17-7 ii libtinfo5 5.9+20130608-1 Versions of packages bash recommends: ii bash-completion 1:2.0-1 Versions of packages bash suggests: ii bash-doc 4.2+dfsg-1 -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org