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
100df0f2
Commit
100df0f2
authored
Aug 18, 2011
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12650: only run the tests on Unix.
parent
b02302c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
58 deletions
+58
-58
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+58
-58
No files found.
Lib/test/test_subprocess.py
View file @
100df0f2
...
...
@@ -945,6 +945,64 @@ class POSIXProcessTestCase(BaseTestCase):
self
.
assertEqual
(
0
,
p
.
returncode
,
"sigchild_ignore.py exited"
" non-zero with this error:
\
n
%s"
%
stderr
)
def
test_zombie_fast_process_del
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
# process exited, it wouldn't be added to subprocess._active, and would
# remain a zombie.
# spawn a Popen, and delete its reference before it exits
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import sys, time;'
'time.sleep(0.2)'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
ident
=
id
(
p
)
pid
=
p
.
pid
del
p
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# sleep a little to let the process exit, and create a new Popen: this
# should trigger the wait() of p
time
.
sleep
(
1
)
with
self
.
assertRaises
(
EnvironmentError
)
as
c
:
with
subprocess
.
Popen
([
'nonexisting_i_hope'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
proc
:
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_leak_fast_process_del_killed
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
# process exited, and the process got killed by a signal, it would never
# be removed from subprocess._active, which triggered a FD and memory
# leak.
# spawn a Popen, delete its reference and kill it
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import time;'
'time.sleep(3)'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
ident
=
id
(
p
)
pid
=
p
.
pid
del
p
os
.
kill
(
pid
,
signal
.
SIGKILL
)
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# let some time for the process to exit, and create a new Popen: this
# should trigger the wait() of p
time
.
sleep
(
0.2
)
with
self
.
assertRaises
(
EnvironmentError
)
as
c
:
with
subprocess
.
Popen
([
'nonexisting_i_hope'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
proc
:
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
@
unittest
.
skipUnless
(
mswindows
,
"Windows specific tests"
)
class
Win32ProcessTestCase
(
BaseTestCase
):
...
...
@@ -1080,64 +1138,6 @@ class HelperFunctionTests(unittest.TestCase):
subprocess
.
_eintr_retry_call
(
fake_os_func
,
666
))
self
.
assertEqual
([(
256
,
999
),
(
666
,),
(
666
,)],
record_calls
)
def
test_zombie_fast_process_del
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
# process exited, it wouldn't be added to subprocess._active, and would
# remain a zombie.
# spawn a Popen, and delete its reference before it exits
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import sys, time;'
'time.sleep(0.2)'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
ident
=
id
(
p
)
pid
=
p
.
pid
del
p
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# sleep a little to let the process exit, and create a new Popen: this
# should trigger the wait() of p
time
.
sleep
(
1
)
with
self
.
assertRaises
(
EnvironmentError
)
as
c
:
with
subprocess
.
Popen
([
'nonexisting_i_hope'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
proc
:
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
def
test_leak_fast_process_del_killed
(
self
):
# Issue #12650: on Unix, if Popen.__del__() was called before the
# process exited, and the process got killed by a signal, it would never
# be removed from subprocess._active, which triggered a FD and memory
# leak.
# spawn a Popen, delete its reference and kill it
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import time;'
'time.sleep(3)'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
ident
=
id
(
p
)
pid
=
p
.
pid
del
p
os
.
kill
(
pid
,
signal
.
SIGKILL
)
# check that p is in the active processes list
self
.
assertIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
# let some time for the process to exit, and create a new Popen: this
# should trigger the wait() of p
time
.
sleep
(
0.2
)
with
self
.
assertRaises
(
EnvironmentError
)
as
c
:
with
subprocess
.
Popen
([
'nonexisting_i_hope'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
proc
:
pass
# p should have been wait()ed on, and removed from the _active list
self
.
assertRaises
(
OSError
,
os
.
waitpid
,
pid
,
0
)
self
.
assertNotIn
(
ident
,
[
id
(
o
)
for
o
in
subprocess
.
_active
])
@
unittest
.
skipUnless
(
mswindows
,
"mswindows only"
)
class
CommandsWithSpaces
(
BaseTestCase
):
...
...
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