Commit Graph

208 Commits

Author SHA1 Message Date
Gregory P. Smith 589ecda56e Fixes issue #19929: Call os.read with 32768 within subprocess.Popen
communicate rather than 4096 for efficiency.  A microbenchmark shows
Linux and OS X both using ~50% less cpu time this way.
2013-12-08 10:56:07 -08:00
Gregory P. Smith 774f909489 Fixes issue #19506: Use a memoryview to avoid a data copy when piping data
to stdin within subprocess.Popen.communicate.  5-10% less cpu usage.
2013-12-07 19:12:46 -08:00
Gregory P. Smith 361e30c17a Undo supposed fix for Issue #15798 until I understand why this is
causing test_multiprocessing_forkserver and test_multiprocessing_spawn
failures on head (3.4).
2013-12-01 00:12:24 -08:00
Gregory P. Smith 1eda9e7c30 Fixes Issue #15798 - subprocess.Popen() no longer fails if file
descriptor 0, 1 or 2 is closed.
2013-11-30 19:02:57 -08:00
Tim Golden acea823fd8 Remove outdated comment 2013-11-11 15:08:04 +00:00
Tim Golden e004175c56 Issue #10197 Rework subprocess.get[status]output to use subprocess functionality and thus to work on Windows. Patch by Nick Coghlan. 2013-11-03 12:53:17 +00:00
Ezio Melotti 30b9d5d3af #18705: fix a number of typos. Patch by Févry Thibault. 2013-08-17 15:50:46 +03:00
Ronald Oussoren 385521c90e Cleanup of documentation change from #17860
Reformulated the textual change, and applied it to the docstring as well.
2013-07-07 09:26:45 +02:00
Gregory P. Smith b5461b9884 Prevent a possible double close of parent pipe fds when the subprocess
exec runs into an error.  Prevent a regular multi-close of the /dev/null
fd when any of stdin, stdout and stderr was set to DEVNULL.
2013-06-15 18:04:26 -07:00
Gregory P. Smith a1b9ed32ee Fixes issue #17488: Change the subprocess.Popen bufsize parameter default value
from unbuffered (0) to buffering (-1) to match the behavior existing code
expects and match the behavior of the subprocess module in Python 2 to avoid
introducing hard to track down bugs.
2013-03-23 11:54:22 -07:00
Gregory P. Smith a1ed539268 Fixes issue #17488: Change the subprocess.Popen bufsize parameter default value
from unbuffered (0) to buffering (-1) to match the behavior existing code
expects and match the behavior of the subprocess module in Python 2 to avoid
introducing hard to track down bugs.
2013-03-23 11:44:25 -07:00
Gregory P. Smith 74b24047e3 merge 2013-03-20 18:32:22 -07:00
Gregory P. Smith 1f8a40b81d remove the long obsolete mention of universal newlines mode only being
available when configured at compile time.
2013-03-20 18:32:03 -07:00
Gregory P. Smith 91110f5e55 Use a larger amount of data for tests such as the interrupted_write
tests that depend on filling up an OS pipe so that they work properly
on systems configured with large pipe buffers.
2013-03-19 23:25:16 -07:00
Serhiy Storchaka b3f194d109 Issue #16903: Popen.communicate() on Unix now accepts strings when
universal_newlines is true as on Windows.
2013-02-04 16:47:39 +02:00
Andrew Svetlov 5b187ce700 Keep ref to ECHILD in local scope (#16650) 2012-12-24 20:06:52 +02:00
Andrew Svetlov 08bab07291 Keep ref to ECHILD in local scope (#16650) 2012-12-24 20:06:35 +02:00
Gregory P. Smith c8ac03d936 Fixes issue #16140: The subprocess module no longer double closes its
child subprocess.PIPE parent file descriptors on child error prior to
exec().

This would lead to race conditions in multithreaded programs where
another thread opened a file reusing the fd which was then closed out
from beneath it by the errant second close.
2012-11-11 01:38:18 -08:00
Gregory P. Smith 12489d98e6 Fixes issue #16140: The subprocess module no longer double closes its
child subprocess.PIPE parent file descriptors on child error prior to
exec().

This would lead to race conditions in multithreaded programs where
another thread opened a file reusing the fd which was then closed out
from beneath it by the errant second close.
2012-11-11 01:37:02 -08:00
Gregory P. Smith 6893732c35 Remove the subprocess "bad exception data" warning (formerly a print!)
all together and just include the repr of the data in the exception
itself instead of the useless string "Unknown".

This code path is unlikely to even be possible to take given the
nature of the pipe it gets subprocess data from.
2012-11-11 00:04:52 -08:00
Gregory P. Smith 3aee222122 Remove the subprocess "bad exception data" warning (formerly a print!)
all together and just include the repr of the data in the exception
itself instead of the useless string "Unknown".

This code path is unlikely to even be possible to take given the
nature of the pipe it gets subprocess data from.
2012-11-11 00:04:13 -08:00
Gregory P. Smith 1f83866ecd Rename a local variable for readability and change a "this can't
happen" print() call into a RuntimeWarning as it should've been in the
first place.  Because nothing should ever cause unexpected stdout output.
2012-11-10 23:33:56 -08:00
Gregory P. Smith f44c9da166 Rename a local variable for readability and change a "this can't
happen" print() call into a RuntimeWarning as it should've been in the
first place.  Because nothing should ever cause unexpected stdout output.
2012-11-10 23:33:17 -08:00
Gregory P. Smith 561cbc4e7b Fixes issue #16327: The subprocess module no longer leaks file descriptors
used for stdin/stdout/stderr pipes to the child when fork() fails.
2012-11-10 22:33:23 -08:00
Gregory P. Smith 3d8e776cd9 Fixes issue #16327: The subprocess module no longer leaks file descriptors
used for stdin/stdout/stderr pipes to the child when fork() fails.
2012-11-10 22:32:22 -08:00
Gregory P. Smith f328d79223 Fixes issue #14396: Handle the odd rare case of waitpid returning 0
when not expected in subprocess.Popen.wait().
2012-11-10 21:06:18 -08:00
Gregory P. Smith 2ec82331b2 Fixes issue #14396: Handle the odd rare case of waitpid returning 0 when
not expected in subprocess.Popen.wait().
2012-11-10 20:52:29 -08:00
Gregory P. Smith a10ddb8a55 Fixes Issue #16114: The subprocess module no longer provides a
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.
2012-10-10 03:44:47 -07:00
Gregory P. Smith 5591b02a4c Fixes Issue #16114: The subprocess module no longer provides a
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.
2012-10-10 03:34:47 -07:00
Gregory P. Smith 02dee1acd8 Fixes issue #15756: subprocess.poll() now properly handles errno.ECHILD
to return a returncode of 0 when the child has already exited or cannot be
waited on.
2012-09-29 11:53:08 -07:00
Gregory P. Smith 3905171f1e Fixes issue #15756: subprocess.poll() now properly handles errno.ECHILD
to return a returncode of 0 when the child has already exited or cannot
be waited on.
2012-09-29 11:40:38 -07:00
Andrew Svetlov a19de803e4 Issue #15595: Fix subprocess.Popen(universal_newlines=True)
for certain locales (utf-16 and utf-32 family).

Patch by Chris Jerdonek.
2012-08-19 22:20:03 +03:00
Andrew Svetlov 828607170d Issue #15595: Fix subprocess.Popen(universal_newlines=True)
for certain locales (utf-16 and utf-32 family).

Patch by Chris Jerdonek.
2012-08-19 22:13:41 +03:00
Andrew Svetlov 377a152e0d Use Thread.is_alive() instead of old-style Thread.isAlive() in subprocess. 2012-08-19 20:49:39 +03:00
Andrew Svetlov 592df20efc Cleanup universal_newlines usage for subprocess.Popen, remove unused param. 2012-08-15 17:36:15 +03:00
Andrew Svetlov aa0dbdc2dd Issue #15592. Fix regression: subprocess.communicate() breaks on no input with universal newlines true.
Patch by Chris Jerdonek.
2012-08-14 18:40:21 +03:00
Victor Stinner 949d8c986e Close #14690: Use monotonic clock instead of system clock in the sched,
subprocess and trace modules.
2012-05-30 13:30:32 +02:00
Vinay Sajip 7ded1f0f69 Implemented PEP 405 (Python virtual environments). 2012-05-26 03:45:29 +01:00
Antoine Pitrou ebdcd859e5 Move private function _args_from_interpreter_flags() to subprocess.py, so
that it can be imported when threads are disabled.
(followup to issue #12098)
2012-05-18 18:33:07 +02:00
Antoine Pitrou 23bba4ca39 Issue #11750: The Windows API functions scattered in the _subprocess and
_multiprocessing.win32 modules now live in a single module "_winapi".
Patch by sbt.
2012-04-18 20:51:15 +02:00
Antoine Pitrou b69ef16fe6 Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. 2012-03-11 19:33:29 +01:00
Antoine Pitrou 1f9a835400 Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. 2012-03-11 19:29:12 +01:00
Antoine Pitrou 24d659daaf Use InterruptedError instead of checking for EINTR 2011-10-23 23:49:42 +02:00
Victor Stinner c15c88c13d Issue #12494: Close pipes and kill process on error in subprocess functions
On error, call(), check_call(), check_output() and getstatusoutput() functions
of the subprocess module now kill the process, read its status (to avoid
zombis) and close pipes.
2011-09-01 23:45:04 +02:00
Charles-François Natali 558639f0c9 Issue #12650: Fix a race condition where a subprocess.Popen could leak
resources (FD/zombie) when killed at the wrong time.
2011-08-18 19:11:29 +02:00
Charles-François Natali 134a8baed9 Issue #12650: Fix a race condition where a subprocess.Popen could leak
resources (FD/zombie) when killed at the wrong time.
2011-08-18 18:49:39 +02:00
Ross Lagerwall d98646e430 Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
given as a low fd, it gets overwritten.
2011-07-27 07:16:31 +02:00
Antoine Pitrou e02891b459 Issue #12591: Improve support of "universal newlines" in the subprocess
module: the piped streams can now be properly read from or written to.
2011-07-23 22:04:41 +02:00
Antoine Pitrou ab85ff3d1a Issue #12591: Improve support of "universal newlines" in the subprocess
module: the piped streams can now be properly read from or written to.

(this was broken due to the 2.x to 3.x transition; communicate() support
is still sketchy)
2011-07-23 22:03:45 +02:00
Victor Stinner 5b1261d750 (merge 3.2) Issue #12493: subprocess: communicate() handles EINTR
subprocess.Popen.communicate() now also handles EINTR errors if the process has
only one pipe.
2011-07-05 14:04:39 +02:00