cpython: 41b1fe5a75a6 (original) (raw)

Mercurial > cpython

changeset 75524:41b1fe5a75a6 3.2

Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited. [#14252]

Antoine Pitrou solipsis@pitrou.net
date Sun, 11 Mar 2012 19:29:12 +0100
parents a5b073b1cfea
children f452d7d5470d 3f15c069454d 15550b5777b9
files Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS PC/_subprocess.c
diffstat 4 files changed, 82 insertions(+), 1 deletions(-)[+] [-] Lib/subprocess.py 12 Lib/test/test_subprocess.py 67 Misc/NEWS 3 PC/_subprocess.c 1

line wrap: on

line diff

--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1075,7 +1075,17 @@ class Popen(object): def terminate(self): """Terminates the process """

kill = terminate

--- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -989,6 +989,27 @@ class POSIXProcessTestCase(BaseTestCase) getattr(p, method)(*args) return p

+ def test_send_signal(self): p = self._kill_process('send_signal', signal.SIGINT) _, stderr = p.communicate() @@ -1007,6 +1028,18 @@ class POSIXProcessTestCase(BaseTestCase) self.assertStderrEqual(stderr, b'') self.assertEqual(p.wait(), -signal.SIGTERM)

+

+

+ def check_close_std_fds(self, fds): # Issue #9905: test that subprocess pipes still work properly with # some standard fds closed @@ -1568,6 +1601,31 @@ class Win32ProcessTestCase(BaseTestCase) returncode = p.wait() self.assertNotEqual(returncode, 0)

+ def test_send_signal(self): self._kill_process('send_signal', signal.SIGTERM) @@ -1577,6 +1635,15 @@ class Win32ProcessTestCase(BaseTestCase) def test_terminate(self): self._kill_process('terminate')

+

+

+

The module says:

"NB This only works (and is only relevant) for UNIX."

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,9 @@ Core and Builtins Library ------- +- Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under

--- a/PC/_subprocess.c +++ b/PC/_subprocess.c @@ -684,6 +684,7 @@ PyInit__subprocess() defint(d, "WAIT_OBJECT_0", WAIT_OBJECT_0); defint(d, "CREATE_NEW_CONSOLE", CREATE_NEW_CONSOLE); defint(d, "CREATE_NEW_PROCESS_GROUP", CREATE_NEW_PROCESS_GROUP);

return m; }