-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use os.posix_spawn when available (i.e, 3.8) #53
Comments
fd & tty should be non-inheritable already (by default), so there would be no race and the os.set_inheritable and POSIX_SPAWN_CLOSE are both unnecessary. Documentation states that all FDs are non-inheritable by default in Python 3.4+, and I have confirmed this in Python 3.6.6. |
The race is in os.openpty(). Since openpty() returns an inheritable master and slave, a parallel for made after openpty() returns but before inheritable is cleared would inherit those FDs.
but yes, the os.set_inheritable and POSIX_SPAWN_CLOSE could be dropped |
That region of code is protected by the GIL. No race. |
(Copying my comment from #52) I don't know how to combine the |
The attached patch is an experiment in using Python 3.8's os.posix_spawn() in ptyprocess. Since it doesn't use fork() it eliminates all those problems. A simple test using pexpect.interact() seemed to work.
I know it has a race with inheritable when called in parallel; and I'm sure there's more.
ptyprocess-posix-spawn.patch.gz
The change looks bigger than it is because I indented all the old code. Below is what matters, which I've included so it is easier to pick it apart....
The text was updated successfully, but these errors were encountered: