Commit Graph

75 Commits

Author SHA1 Message Date
Brian Curtin e5aa886b44 Implement #1220212. Add os.kill support for Windows.
os.kill takes one of two newly added signals, CTRL_C_EVENT and
CTRL_BREAK_EVENT, or any integer value. The events are a special case
which work with subprocess console applications which implement a
special console control handler. Any other value but those two will
cause os.kill to use TerminateProcess, outright killing the process.

This change adds win_console_handler.py, which is a script to implement
SetConsoleCtrlHandler and applicable handler function, using ctypes.

subprocess also gets another attribute which is a necessary flag to
creationflags in Popen in order to send the CTRL events.
2010-04-02 23:26:06 +00:00
Florent Xicluna cf741ceb69 Fix syntax: "rc != None" -> "rc is not None" 2010-03-08 10:58:12 +00:00
Gregory P. Smith cce211f88c Issue #1068268: The subprocess module now handles EINTR in internal
os.waitpid and os.read system calls where appropriate.
2010-03-01 00:05:08 +00:00
Georg Brandl 84fedf7f06 No need to assign the results of expressions used only for side effects. 2010-02-06 22:59:15 +00:00
Georg Brandl 02e7dfde63 #7381: consistency update, and backport avoiding ``None >= 0`` check from py3k. 2009-12-28 08:09:32 +00:00
Georg Brandl 6ab5d083f2 #7381: subprocess documentation and library docstring consistency fixes. 2009-12-20 14:33:20 +00:00
Eric Smith d19915ed76 Issue 7294: Fixed URL in a comment. 2009-11-09 15:16:23 +00:00
Philip Jenvey 8b9020458a #5329: fix os.popen* regression from 2.5: don't execute commands as a sequence
through the shell. also document the correct subprocess replacement for this
case
patch from Jean-Paul Calderone and Jani Hakala
2009-09-29 19:10:15 +00:00
Georg Brandl 3e8b869c9c Revert r74028. 2009-07-16 21:47:51 +00:00
Georg Brandl 3601a38029 #6482: simplify "except: raise" to "finally:". 2009-07-16 19:24:48 +00:00
Amaury Forgeot d'Arc 8318afa0b8 #6447: typo in subprocess docstring 2009-07-10 16:47:42 +00:00
Amaury Forgeot d'Arc ce32eb7406 #6416: Fix compilation of the select module on Windows, as well as test_subprocess:
PIPE_BUF is not defined on Windows, and probably has no meaning there.

Anyway the subprocess module uses another way to perform non-blocking reads (with a thread)
2009-07-09 22:37:22 +00:00
Gregory P. Smith dd7ca24eb5 Use select.poll() in subprocess, when available, rather than select() so that
it does not fail when file descriptors are large.  Fixes issue3392.

Patch largely contributed by Frank Chu (fpmc) with some improvements by me.
See http://bugs.python.org/issue3392.

Candidate for backporting to release26-maint as it is a bug fix and changes no
public API.
2009-07-04 01:49:29 +00:00
Facundo Batista 8c826b77e0 Issue #6274. Fixed a potential FD leak in subprocess.py. 2009-06-19 18:02:28 +00:00
Amaury Forgeot d'Arc 5fe420e34c #6189: The subprocess.py module should be kept compatible with python 2.2
(On windows, you still have to change one line to use pywin32
instead of the _subprocess helper module)
2009-06-18 22:32:50 +00:00
Hirokazu Yamamoto eacbbdfb73 Issue #5179: Fixed subprocess handle leak on failure on windows. 2009-03-03 22:18:14 +00:00
Mark Dickinson 3e4caeb3bf Issue #5341: Fix a variety of spelling errors. 2009-02-21 20:27:01 +00:00
Georg Brandl f3715d2fc7 #5179: don't leak PIPE fds when child execution fails. 2009-02-14 17:01:36 +00:00
Gregory P. Smith 26576801a6 rename the new check_call_output to check_output. its less ugly. 2008-12-05 02:27:01 +00:00
Gregory P. Smith 97f49f4be7 Adds a subprocess.check_call_output() function to return the output from a
process on success or raise an exception on error.
2008-12-04 20:21:09 +00:00
Brett Cannon 03446c43ca Remove warnings generated for the suprocess module when run under -3. Required
commenting out True/False compatbility stuff, remove a use of apply(), and
remove a use of buffer() (just pulled the solution used in 3.0 which is direct
slicing).
2008-08-08 04:19:32 +00:00
Gregory P. Smith a36f8fefb0 - Issue #1857: subprocess.Popen.poll gained an additional _deadstate keyword
argument in python 2.5, this broke code that subclassed Popen to include its
  own poll method.  Fixed my moving _deadstate to an _internal_poll method.
2008-08-04 00:13:29 +00:00
Gregory P. Smith f41406409e - Issue #2113: Fix error in subprocess.Popen if the select system call is
interrupted by a signal.
2008-07-06 07:16:40 +00:00
Gregory P. Smith 4036fd4b75 Fixes issue2791: subprocess.Popen.communicate leaked a file descripton until
the last reference to the Popen instance was dropped.  Adding explicit
close() calls fixes it.

Candidate for backport to release25-maint.
2008-05-26 20:22:14 +00:00
Christian Heimes e74c8f2879 Added kill, terminate and send_signal to subprocess.Popen
The bits and pieces for the Windows side were already in place. The POSIX side is trivial (as usual) and uses os.kill().
2008-04-19 02:23:57 +00:00
Gregory P. Smith 70eb2f91b4 Fix issue 1300: Quote command line arguments that contain a '|' character in
subprocess.list2cmdline (windows).
2008-01-19 22:49:37 +00:00
Gregory P. Smith 92ffc634e4 Undo an unnecessary else: and indentation that r60104 added.
try:
  ...
except:
  ...
  raise
else:
  ...

the else: is unecessary due to the blind except: with a raise.
2008-01-19 22:23:56 +00:00
Gregory P. Smith 87d49792b5 Fixes issue1336 - a race condition could occur when forking if the gc
kicked in during the critical section.  solution: disable gc during
that section.  Patch contributed by jpa and updated by me to cover the
race condition still existing what therve from twistedmatrix pointed
out (already seen and fixed in twisted's own subprocess code).
2008-01-19 20:57:59 +00:00
Gregory P. Smith e047e6dd09 fix comment typos, use not arg instead of arg == "", add test coverage
for inside of the final if needquotes: within subprocess.list2cmdline().
2008-01-19 20:49:02 +00:00
Georg Brandl 309501a617 #1663329: add os.closerange() to close a range of fds,
ignoring errors, and use this in subprocess to speed up
subprocess creation in close_fds mode. Patch by Mike Klaas.
2008-01-19 20:22:13 +00:00
Peter Astrand 81a191b351 Applied patch 1669481, slightly modified: Support close_fds on Win32 2007-05-26 22:18:20 +00:00
Neal Norwitz 82be218e97 Remove trailing whitespace in docstring 2007-05-11 06:56:52 +00:00
Neal Norwitz aa87fb6be4 Fix typo in docstring (the module is popen2, not 3). 2007-05-11 06:23:01 +00:00
Georg Brandl 24522982d0 Bug #1704790: bind name "sys" locally in __del__ method so that it is
not cleared before __del__ is run.
2007-04-21 20:35:38 +00:00
Tim Peters ea5962f86e Whitespace normalization. 2007-03-12 18:07:52 +00:00
Peter Astrand 5f9c6ae545 Applied patch 1124861.3.patch to solve bug #1124861: Automatically create pipes on Windows, if GetStdHandle fails. Will backport. 2007-02-06 15:37:50 +00:00
Peter Astrand f54000325b We had several if statements checking the value of a fd. This is unsafe, since valid fds might be zero. We should check for not None instead. 2007-02-02 19:06:36 +00:00
Tim Peters f733abb783 Whitespace normalization. 2007-01-30 03:03:46 +00:00
Peter Astrand 10514a70ac Fix for bug #1634343: allow specifying empty arguments on Windows 2007-01-13 22:35:35 +00:00
Peter Astrand 1812f8cf3f Avoid O(N**2) bottleneck in _communicate_(). Fixes #1598181. 2007-01-07 14:34:16 +00:00
Peter Astrand ec05a2d580 Re-implemented fix for #1531862 once again, in a way that works with Python 2.2. Fixes bug #1603424. 2007-01-07 08:53:46 +00:00
Neal Norwitz a186ee22c0 SF bug #1623890, fix argument name in docstring 2006-12-29 03:01:53 +00:00
Georg Brandl 6c0e1e8673 Bug #1357915: allow all sequence types for shell arguments in
subprocess.
2006-10-29 09:05:04 +00:00
Gustavo Niemeyer c36bede6ff Fixed subprocess bug #1531862 again, after removing tests
offending buildbot
2006-09-07 00:48:33 +00:00
Neal Norwitz 314bef9fff Revert 51758 because it broke all the buildbots 2006-09-06 03:58:34 +00:00
Gustavo Niemeyer 8cb64eaaf3 Fixing #1531862: Do not close standard file descriptors in the
subprocess module.
2006-09-06 01:58:52 +00:00
Georg Brandl 13cf38c0cf Guard for _active being None in __del__ method. 2006-07-20 16:28:39 +00:00
Tim Peters 73a9eade1c Whitespace normalization. 2006-07-18 21:55:15 +00:00
Peter Astrand 7d1d43630e Bug #1223937: CalledProcessError.errno -> CalledProcessError.returncode. 2006-07-14 14:04:45 +00:00
Neal Norwitz 8440483fea Fix doco. Backport candidate. 2006-07-10 00:05:34 +00:00