| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
When os.fork() is called (on platforms that support it) all threads but the current one are destroyed in the child process. Consequently we must ensure that all but the associated interpreter are likewise destroyed. The main interpreter is critical for runtime operation, so we must ensure that fork only happens in the main interpreter.
https://bugs.python.org/issue34651
|
|
|
|
|
|
|
|
|
| |
[bpo-34658](https://www.bugs.python.org/issue34658): Fix a rare interpreter unhandled exception state SystemError only
seen when using subprocess with a preexec_fn while an after_parent handler has
been registered with os.register_at_fork and the fork system call fails.
https://bugs.python.org/issue34658
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When subprocess.Popen() stdin= stdout= or stderr= handles are specified
and appear in pass_fds=, don't close the original fds after dup'ing them.
This implementation and unittest primarily came from @izbyshev (see the PR)
See also https://github.com/izbyshev/cpython/commit/b89b52f28490b69142d5c061604b3a3989cec66c
This also removes the old manual p2cread, c2pwrite, and errwrite closing logic
as inheritable flags and _close_open_fds takes care of that properly today without special treatment.
This code is within child_exec() where it is the only thread so there is no
race condition between the dup and _Py_set_inheritable_async_safe call.
|
|
|
|
|
|
|
|
|
|
| |
bpo-32844: subprocess: Fix a potential misredirection of a low fd to stderr.
When redirecting, subprocess attempts to achieve the following state:
each fd to be redirected to is less than or equal to the fd
it is redirected from, which is necessary because redirection
occurs in the ascending order of destination descriptors.
It fails to do so in a couple of corner cases,
for example, if 1 is redirected to 2 and 0 is closed in the parent.
|
|
|
|
|
|
|
| |
Fix a rare but potential pre-exec child process deadlock in subprocess on POSIX systems when marking file descriptors inheritable on exec in the child process. This bug appears to have been introduced in 3.4 with the inheritable file descriptors support.
This also changes Python/fileutils.c `set_inheritable` to use the "slow" two `fcntl` syscall path instead of the "fast" single `ioctl` syscall path when asked to be async signal safe (by way of being asked not to raise exceptions). `ioctl` is not a POSIX async-signal-safe approved function.
ref: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
|
| |
|
|
|
|
| |
Instead use keyword only arguments to os.register_at_fork for each of the scenarios.
Updates the documentation for clarity.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* bpo-16500: Allow registering at-fork handlers
* Address Serhiy's comments
* Add doc for new C API
* Add doc for new Python-facing function
* Add NEWS entry + doc nit
|
| |
|
|\ |
|
| | |
|
| | |
|
|/
|
|
| |
private functions.
|
|\ |
|
| |
| |
| |
| | |
Also fix handling of failure to release the import lock.
|
| |
| |
| |
| |
| | |
internals regarding how fds_to_pass were passed to the child. The bug
had no actual impact as subprocess.py already avoided it.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Add "#ifdef WITH_THREAD" around cals to:
* PyGILState_Check()
* _PyImport_AcquireLock()
* _PyImport_ReleaseLock()
|
|\ \
| |/ |
|
| | |
|
| |
| |
| |
| | |
Also update _posixsubprocess to use Py_hexdigits instead of its own constant.
|
|\ \
| |/ |
|
| |
| |
| |
| | |
See the PEP 475 for the rationale.
|
| |
| |
| |
| | |
_posixsubprocess
|
| |
| |
| |
| |
| |
| |
| | |
Don't call _Py_open() from _close_open_fds_safe() because it is call just after
fork(). It's not good to play with locks (the GIL) between fork() and exec().
Use instead _Py_open_noraise() which doesn't touch to the GIL.
|
|/
|
|
|
|
|
|
| |
* _Py_open() now raises exceptions on error. If open() fails, it raises an
OSError with the filename.
* _Py_open() now releases the GIL while calling open()
* Add _Py_open_noraise() when _Py_open() cannot be used because the GIL is not
held
|
|
|
|
|
|
|
|
| |
* Don't call the garbage collector with an exception set: it causes an
assertion to fail in debug mode.
* Enhance also error handling if allocating an array for the executable list
failed.
* Add an unit test for 4 different errors in the _posixsubprocess module.
|
| |
|
|
|
|
|
|
|
|
|
| |
when we have a way to get an actual list of all open fds from the OS.
Fixes issue #21618: The subprocess module would ignore fds that were
inherited by the calling process and already higher than POSIX resource
limits would otherwise allow. On systems with a functioning /proc/self/fd
or /dev/fd interface the max is now ignored and all fds are closed.
|
|
|
|
|
|
| |
Fixes issue20307. No Misc/NEWS entry because frankly this is an
esoteric platform for anyone to be figuring out how to cross compile
CPython for.
|
|\
| |
| |
| |
| | |
causing test_multiprocessing_forkserver and test_multiprocessing_spawn
failures on head (3.4).
|
| |
| |
| |
| |
| | |
causing test_multiprocessing_forkserver and test_multiprocessing_spawn
failures on head (3.4).
|
|\ \
| |/
| |
| | |
descriptor 0, 1 or 2 is closed.
|
| |
| |
| |
| | |
descriptor 0, 1 or 2 is closed.
|
| |
| |
| |
| |
| | |
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
|
|\ \
| |/ |
|
| |
| |
| |
| | |
preexec_fn callback, which may open file descriptors.
|
|\ \
| |/
| |
| | |
in the subprocess module on Linux.
|
| |
| |
| |
| | |
the subprocess module on Linux.
|
|/
|
|
| |
odd rare errors coming from the subprocess module.
|
|\
| |
| |
| |
| |
| | |
misleading error message stating that args[0] did not exist when
either the cwd or executable keyword arguments specified a path that
did not exist.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
misleading error message stating that args[0] did not exist when
either the cwd or executable keyword arguments specified a path that
did not exist.
It now keeps track of if the child got as far as preexec and reports it if
not back to the parent via a special "noexec" error message value in
the error pipe so that the cwd can be blamed for a failed chdir
instead of the exec of the executable being blamed instead.
The executable is also always reported accurately when exec fails.
Unittests enhanced to cover these cases.
|
|\ \
| |/ |
|
| |
| |
| |
| | |
It was exposed by 03c98d05b140 and dbbf3ccf72e8.
|
|\ \
| |/ |
|
| | |
|
|\ \
| |/
| |
| |
| |
| | |
errors correctly.
Patch by Serhiy Storchaka.
|
| |
| |
| |
| |
| |
| | |
errors correctly.
Patch by Serhiy Storchaka.
|
|\ \
| |/ |
|
| | |
|
| |
| |
| |
| | |
Based on patch from Hervé Coatanhay.
|