Ticket #40767

Defaulting SIGQUIT in asynchronous subshell

Open Date: 2020-09-24 12:11 Last Update: 2020-10-12 00:29

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
None
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

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=$!
sleep 1
kill -QUIT $pid
wait $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

Ticket History (3/5 Histories)

2020-09-24 12:11 Updated by: magicant
  • New Ticket "Defaulting SIGQUIT in subshell" created
2020-10-07 07:49 Updated by: magicant
Comment

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.

2020-10-07 22:27 Updated by: magicant
  • Summary Updated
2020-10-07 22:33 Updated by: magicant
Comment

I think I have to extend the test cases in trap-p.tst to cover more signals, not only USR1 and few others.

2020-10-12 00:29 Updated by: magicant
  • Status Update from Open to Closed
  • Resolution Update from None to Fixed
Comment

Fixed in r4114

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login