-
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.
Fix race conditions running external commands with job control on
When ksh is compiled with SHOPT_SPAWN (the default), which uses posix_spawn(3) or vfork(2) (via sh_ntfork()) to launch external commands, at least two race conditions occur when launching external commands while job control is active. See: https://bugs.launchpad.net/ubuntu/+source/ksh/+bug/1887863/comments/3 https://www.mail-archive.com/[email protected]/msg00717.html The basic issue is that this performance optimisation is incompatible with job control, because it uses a spawning mechanism that doesn't copy the parent process' memory pages into the child process, therefore no state that involves memory can be set before exec-ing the external program. This makes it impossible to correctly set the terminal's process group ID in the child process, something that is essential for job control to work. src/cmd/ksh93/sh/xec.c: - Use sh_fork() instead of sh_ntfork() if job control is active. This uses fork(2), which is 30%-ish slower on most sytems, but allows for correctly setting the terminal process group. src/cmd/ksh93/tests/basic.sh: - Add regression test for the race condition reported in #79. src/cmd/INIT/cc.darwin: - Remove hardcoded flag to disable SHOPT_SPAWN on the Mac. It should be safe to use now. Fixes #79
- Loading branch information
Showing
5 changed files
with
26 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
* David Korn <[email protected]> * | ||
* * | ||
***********************************************************************/ | ||
#define SH_RELEASE "93u+m 2020-07-20" | ||
#define SH_RELEASE "93u+m 2020-07-22" |
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