Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use fork()/exec() instead of posix_spawn() by default
Using posix_spawn() may result in a race condition while setting terminal foreground process group. Copying dgk's response from related discussion in ast-developers mailing list: " ksh93 uses posix_spawn() rather than fork/exec to run a simple command for performance reasons. However, posix_spawnv() doesn't have a way to set the terminal group before the exec(). The parent process sets the terminal group which leads to the race. There is a simple change you can make to a program to guarentee that the terminal will get set at the beginning of the program. You can add two lines. One line is #include <termios.h> and for the other line tcsetpgrp(2,getpgrp()); Alternatively, you can write a program that does these two lines and then execs the original program. " Only way to reliably fix this problem in ksh is to switch back to fork()/ exec(). If there are any performance regressions or bugs caused by this change, you can switch to posix_spawn() by setting '-D_AST_no_spawnveg=0'. Related: #468 Related: rhbz#1160482
- Loading branch information