-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kill: do not send SIGCONT along with every signal (!)
Reproducer 1: $ ksh -c 'trap "echo SIGCONT" CONT; trap "echo SIGUSR1" USR1; kill -s USR1 $$' SIGUSR1 SIGCONT Why on earth is the SIGCONT trap triggered? Turns out the 'kill' command sends SIGCONT as well as SIGUSR1, which is very wrong. No other shell acts like this and neither does any external 'kill' command, and of course this violates POSIX as well. Reproducer 2: $ ksh $ suspend [1] + Stopped (SIGSTOP) ksh $ kill %% $ $ t $ es $ t After suspending the child ksh, 'kill %%' is supposed to send it SIGTERM, which is ignored by an interactive shell. But it also wrongly sends it SIGCONT, resuming it while it is still in the background. So now you have two shells competing for your keybaord input, and chaos ensues. The above reproducer shows a possible result of typing 'test' (with no RETURN key). Archaeological research shows that the offending code was present as early as ksh88, so the reasons are lost to history. src/cmd/ksh93/sh/jobs.c: job_kill(): - Remove code sending SIGCONT along with every signal. - Only clear the P_STOPPED flag in the job entry or call job_unstop() if the signal is SIGCONT. - Tweak for code legibility.
- Loading branch information
Showing
4 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters