8 Feb 2012 18:27
bug in handling of ignored traps
Eric Blake <eblake <at> redhat.com>
2012-02-08 17:27:29 GMT
2012-02-08 17:27:29 GMT
Per POSIX requirements on trap, dash is properly refusing to let non-interactive scripts reset signal handlers via trap if the shell was started with an inherited ignored signal handler. However, dash lies to the user, making it impossible to tell if the user is invoking a shell in an environment where a signal was inherited as ignored. ksh and bash are nicer about things, and at least let the user query whether a shell is treating a particular signal as non-resettable. This is important for shell scripts that WANT to guarantee a particular behavior of SIGPIPE handling (such as this thread on writing a grep test for covering the behavior of grep both with and without SIGPIPE inherited as ignored: https://lists.gnu.org/archive/html/bug-grep/2012-02/msg00016.html). Bash behavior - you can learn about the ignored handler from the get-go: $ (trap '' PIPE; bash -c 'trap; echo 0; trap "echo 1" PIPE; trap; \ echo 2; kill -s PIPE $$; trap; echo 3') trap -- '' SIGPIPE 0 trap -- '' SIGPIPE 2 trap -- '' SIGPIPE 3 Ksh behavior - you can learn about the ignored handler, but only after trying to use something else: $ (trap '' PIPE; ksh -c 'trap; echo 0; trap "echo 1" PIPE; trap; \ echo 2; kill -s PIPE $$; trap; echo 3')(Continue reading)
RSS Feed