Spurious suspension in job-control tests
This patch will also reveal the issue.
- diff --git a/tests/Makefile.in b/tests/Makefile.in
- index f6074603..32fdc67a 100644
- --- a/tests/Makefile.in
- +++ b/tests/Makefile.in
- @@ -65,7 +65,7 @@ $(TEST_RESULTS): $(TESTERS) $(YASH)
- @set $(RUN_TEST) $(TESTEE) $<; \
- if grep -q %REQUIRETTY% $<; then \
- - if ./ptwrap ./checkfg 2>/dev/null; then \
- + if false && ./ptwrap ./checkfg 2>/dev/null; then \
- set ./ptwrap "$$@"; \
- else \
- set $(SHELL) ./enqueue.sh "$$@"; \
Some tests spuriously suspend where it should finish without interruption.
To reproduce, run ../yash run-test.sh ../yash sighup3-p.tst in the tests directory, for example.
The cause of the suspension comes from the test that starts a job-controlling shell that is killed by a subshell: The first test case starts a job-controlling shell that creates a subshell that is assigned a new process group and sends a signal to kill the parent shell. The subshell exits successfully, but the job-controlling shell is gone, so there is no process that comes back to the foreground. The test goes on while the test runner is left in the background. When the next test case starts another job-controlling shell, it checks if it is in the foreground, which is not the case, and suspends itself until it is brought to the foreground. (This is done in the main function by calling the ensure_foreground function.)
The current Makefile uses ptwrap as in ./ptwrap ./resetsig ../yash ./run-test.sh ../yash sighup3-p.tst which works around the issue. It works because with ptwrap the runner becomes a session leader, which bypasses the SIGTTOU signal sent by the tcsetpgrp function. (POSIX forbids the tcsetpgrp function sending SIGTTOU to an orphaned process group.) However, posix-shell-tests does not use ptwrap and thus will suffer this issue.