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
f3715d2f
Commit
f3715d2f
authored
Feb 14, 2009
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#5179: don't leak PIPE fds when child execution fails.
parent
95777bb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
Lib/subprocess.py
Lib/subprocess.py
+3
-0
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+16
-0
No files found.
Lib/subprocess.py
View file @
f3715d2f
...
...
@@ -1151,6 +1151,9 @@ class Popen(object):
if
data
!=
""
:
os
.
waitpid
(
self
.
pid
,
0
)
child_exception
=
pickle
.
loads
(
data
)
for
fd
in
(
p2cwrite
,
c2pread
,
errread
):
if
fd
is
not
None
:
os
.
close
(
fd
)
raise
child_exception
...
...
Lib/test/test_subprocess.py
View file @
f3715d2f
...
...
@@ -520,6 +520,22 @@ class ProcessTestCase(unittest.TestCase):
else
:
self
.
fail
(
"Expected TypeError"
)
def
test_leaking_fds_on_error
(
self
):
# see bug #5179: Popen leaks file descriptors to PIPEs if
# the child fails to execute; this will eventually exhaust
# the maximum number of open fds. 1024 seems a very common
# value for that limit, but Windows has 2048, so we loop
# 1024 times (each call leaked two fds).
for
i
in
range
(
1024
):
try
:
subprocess
.
Popen
([
'nonexisting_i_hope'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
# Windows raises IOError
except
(
IOError
,
OSError
),
err
:
if
err
.
errno
!=
2
:
# ignore "no such file"
raise
#
# POSIX tests
#
...
...
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