summaryrefslogtreecommitdiffstats
path: root/Modules/_posixsubprocess.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-34651: Only allow the main interpreter to fork. (gh-9279)Eric Snow2018-09-141-0/+5
| | | | | 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: Fix rare subprocess prexec_fn fork error. (GH-9255)Gregory P. Smith2018-09-131-7/+13
| | | | | | | | | [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
* bpo-32270: Don't close stdin/out/err in pass_fds (GH-6242)Gregory P. Smith2018-09-111-10/+14
| | | | | | | | | | | | | | 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: Fix a subprocess misredirection of a low fd (GH5689)Alexey Izbyshev2018-03-261-1/+1
| | | | | | | | | | 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.
* bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560)Alexey Izbyshev2018-02-061-4/+4
| | | | | | | 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
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-6/+6
|
* bpo-16500: Don't use string constants for os.register_at_fork() behavior (#1834)Gregory P. Smith2017-05-291-10/+11
| | | | 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 (#1715)Antoine Pitrou2017-05-271-21/+8
| | | | | | | | | | | | * 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
* bpo-30065: Fixed arguments validation in _posixsubprocess.fork_exec(). (#1110)Serhiy Storchaka2017-04-191-20/+23
|
* Issue #20947: Fixed a gcc warning with -Wstrict-overflow.Serhiy Storchaka2016-09-271-1/+1
|\
| * Issue #20947: Fixed a gcc warning with -Wstrict-overflow.Serhiy Storchaka2016-09-271-1/+1
| |
* | Issue #26862: SYS_getdents64 does not need to be defined on android API 21.Xavier de Gaye2016-06-151-2/+1
| |
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
|/ | | | private functions.
* Issue #25764: Merge subprocess fix from 3.4 into 3.5Martin Panter2015-12-051-17/+18
|\
| * Issue #25764: Preserve subprocess fork exception when preexec_fn usedMartin Panter2015-11-301-17/+18
| | | | | | | | Also fix handling of failure to release the import lock.
* | Fixes #23564: Fix a partially broken sanity check in the _posixsubprocessGregory P. Smith2015-11-161-1/+2
| | | | | | | | | | internals regarding how fds_to_pass were passed to the child. The bug had no actual impact as subprocess.py already avoided it.
* | Close #24784: Fix compilation without thread supportVictor Stinner2015-10-111-2/+10
| | | | | | | | | | | | | | | | Add "#ifdef WITH_THREAD" around cals to: * PyGILState_Check() * _PyImport_AcquireLock() * _PyImport_ReleaseLock()
* | Fix computation of max_fd on OpenBSD. Issue #23852.Gregory P. Smith2015-04-261-0/+10
|\ \ | |/
| * Fix computation of max_fd on OpenBSD. Issue #23852.Gregory P. Smith2015-04-261-0/+10
| |
* | Issue9951: update _hashopenssl and md5module to use _Py_strhex().Gregory P. Smith2015-04-251-1/+1
| | | | | | | | Also update _posixsubprocess to use Py_hexdigits instead of its own constant.
* | Merge 3.4 (_posixsubprocess)Victor Stinner2015-04-021-6/+6
|\ \ | |/
| * Issue #23851: close() must not be retried when it fails with EINTRVictor Stinner2015-04-021-6/+6
| | | | | | | | See the PEP 475 for the rationale.
* | Issue #23836: Use _Py_write_noraise() to retry on EINTR in child_exec() ofVictor Stinner2015-04-011-9/+10
| | | | | | | | _posixsubprocess
* | Issue #23694: Fix usage of _Py_open() in the _posixsubprocess moduleVictor Stinner2015-03-301-2/+1
| | | | | | | | | | | | | | 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.
* | Issue #23694: Enhance _Py_open(), it now raises exceptionsVictor Stinner2015-03-171-0/+1
|/ | | | | | | | * _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
* Issue #22290: Fix error handling in the _posixsubprocess module.Victor Stinner2014-10-051-6/+14
| | | | | | | | * 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.
* Fix the comment to not refer to the removed end_fd parameter.Gregory P. Smith2014-06-011-2/+2
|
* Don't restrict ourselves to a "max" fd when closing fds before exec()Gregory P. Smith2014-06-011-43/+44
| | | | | | | | | 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.
* Add conditional code for android's lack of definition of SYS_getdent64.Gregory P. Smith2014-04-141-0/+6
| | | | | | 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.
* Undo supposed fix for Issue #15798 until I understand why this isGregory P. Smith2013-12-011-1/+5
|\ | | | | | | | | causing test_multiprocessing_forkserver and test_multiprocessing_spawn failures on head (3.4).
| * Undo supposed fix for Issue #15798 until I understand why this isGregory P. Smith2013-12-011-1/+5
| | | | | | | | | | causing test_multiprocessing_forkserver and test_multiprocessing_spawn failures on head (3.4).
* | Fixes Issue #15798 - subprocess.Popen() no longer fails if fileGregory P. Smith2013-12-011-5/+1
|\ \ | |/ | | | | descriptor 0, 1 or 2 is closed.
| * Fixes Issue #15798 - subprocess.Popen() no longer fails if fileGregory P. Smith2013-12-011-5/+1
| | | | | | | | descriptor 0, 1 or 2 is closed.
* | Issue #18571: Implementation of the PEP 446: file descriptors and file handlesVictor Stinner2013-08-271-89/+51
| | | | | | | | | | are now created non-inheritable; add functions os.get/set_inheritable(), os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
* | Merge.Charles-François Natali2013-08-251-11/+12
|\ \ | |/
| * Issue #18763: subprocess: The file descriptors are now closed after calling theCharles-François Natali2013-08-251-11/+12
| | | | | | | | preexec_fn callback, which may open file descriptors.
* | Fixes Issue #16962: Use getdents64 instead of the obsolete getdents syscallGregory P. Smith2013-03-031-14/+8
|\ \ | |/ | | | | in the subprocess module on Linux.
| * Issue #16962: Use getdents64 instead of the obsolete getdents syscall inGregory P. Smith2013-03-031-14/+8
| | | | | | | | the subprocess module on Linux.
* | Raise our own SubprocessError rather than a RuntimeError in when dealing withGregory P. Smith2012-11-111-1/+1
|/ | | | odd rare errors coming from the subprocess module.
* Fixes Issue #16114: The subprocess module no longer provides aGregory P. Smith2012-10-101-1/+6
|\ | | | | | | | | | | 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.
| * Fixes Issue #16114: The subprocess module no longer provides aGregory P. Smith2012-10-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge with 3.2Ross Lagerwall2012-08-241-1/+3
|\ \ | |/
| * Issue 15777: Fix a refleak in _posixsubprocess.Ross Lagerwall2012-08-241-1/+3
| | | | | | | | It was exposed by 03c98d05b140 and dbbf3ccf72e8.
* | Merge 3.2.Stefan Krah2012-08-201-0/+2
|\ \ | |/
| * Issue #15738: Fix a missing NULL check in subprocess_fork_exec().Stefan Krah2012-08-201-0/+2
| |
* | Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-4/+3
|\ \ | |/ | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
| * Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-0/+2
| | | | | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
* | Fixes issue #15000: support the odd x32 abi on posixsubprocess's system call.Gregory P. Smith2012-06-051-0/+7
|\ \ | |/
| * Fixes issue #15000: support the odd x32 abi on posixsubprocess's system call.Gregory P. Smith2012-06-051-0/+7
| |
| * Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined.Ross Lagerwall2012-03-191-1/+12
| | | | | | | | Based on patch from Hervé Coatanhay.