Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c9557af4
Commit
c9557af4
authored
May 11, 2011
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge - 7a3f3ad83676 Fixes Issue #12044.
parent
79a11e71
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
3 deletions
+10
-3
Doc/library/subprocess.rst
Doc/library/subprocess.rst
+2
-2
Lib/subprocess.py
Lib/subprocess.py
+2
-0
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+2
-1
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Doc/library/subprocess.rst
View file @
c9557af4
...
...
@@ -217,8 +217,8 @@ This module defines one class called :class:`Popen`:
*creationflags*, if given, can be :data:`CREATE_NEW_CONSOLE` or
:data:`CREATE_NEW_PROCESS_GROUP`. (Windows only)
Popen objects are supported as context managers via the :keyword:`with` statement
,
closing any open file descriptors on exit
.
Popen objects are supported as context managers via the :keyword:`with` statement
:
on exit, standard file descriptors are closed, and the process is waited for
.
::
with Popen(["ifconfig"], stdout=PIPE) as proc:
...
...
Lib/subprocess.py
View file @
c9557af4
...
...
@@ -764,6 +764,8 @@ class Popen(object):
self
.
stderr
.
close
()
if
self
.
stdin
:
self
.
stdin
.
close
()
# Wait for the process to terminate, to avoid zombies.
self
.
wait
()
def
__del__
(
self
,
_maxsize
=
sys
.
maxsize
,
_active
=
_active
):
if
not
self
.
_child_created
:
...
...
Lib/test/test_subprocess.py
View file @
c9557af4
...
...
@@ -1491,7 +1491,8 @@ class ContextManagerTests(ProcessTestCase):
def
test_returncode
(
self
):
with
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"import sys; sys.exit(100)"
])
as
proc
:
proc
.
wait
()
pass
# __exit__ calls wait(), so the returncode should be set
self
.
assertEqual
(
proc
.
returncode
,
100
)
def
test_communicate_stdin
(
self
):
...
...
Misc/NEWS
View file @
c9557af4
...
...
@@ -10,6 +10,10 @@ What's New in Python 3.2.1?
Core and Builtins
-----------------
- Issue #12044: Fixed subprocess.Popen when used as a context manager to
wait for the process to end when exiting the context to avoid unintentionally
leaving zombie processes around.
- Issue #1195: Fix input() if it is interrupted by CTRL+d and then CTRL+c,
clear the end-of-file indicator after CTRL+d.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment