Defaulting SIGQUIT in asynchronous subshell
The following script should finish in one second and print QUIT in the last line, but it actually takes 10 seconds and prints a "no such signal" error.
(trap - QUIT; echo QUIT sleeping...; sleep 10; echo QUIT awake) & pid=$!
kill -QUIT $pid
kill -l $?
This test case is from smoosh's test suite: https://github.com/mgree/smoosh/blob/55bb5bc561191b888bf0e403b7a584c4f7894580/tests/shell/semantics.subshell.background.traps.test
In a non-interactive shell, the trap built-in cannot modify the trap for a signal that was ignored when the shell was invoked. To implement this requirement, when the trap built-in is invoked, we check if the previous trap is unset and the actual signal handler is SIG_IGN before setting the new trap.
https://osdn.net/projects/yash/scm/svn/blobs/4107/yash/trunk/sig.c line 830
This condition is not correct. The handler for SIGQUIT is set to SIG_IGN when an asynchronous subshell is started, which is indistinguishable from a handler that has been set to SIG_IGN since the shell invocation.
I think I have to extend the test cases in trap-p.tst to cover more signals, not only USR1 and few others.
Fixed in r4114