Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
b05ee3d2
Commit
b05ee3d2
authored
Sep 01, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make waitpid(-1) work properly with exited children.
parent
3a265faf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
gevent/os.py
gevent/os.py
+12
-2
greentest/test__monkey_sigchld.py
greentest/test__monkey_sigchld.py
+10
-0
No files found.
gevent/os.py
View file @
b05ee3d2
...
...
@@ -238,8 +238,18 @@ if hasattr(os, 'fork'):
"""
# XXX Does not handle tracing children
if
pid
<=
0
:
# magic functions for multiple children. Pass.
return
_waitpid
(
pid
,
options
)
# magic functions for multiple children.
if
pid
==
-
1
:
# Any child. If we have one that we're watching and that finished,
# we need to use that one. Otherwise, let the OS take care of it.
for
k
,
v
in
_watched_children
.
items
():
if
isinstance
(
v
,
tuple
):
pid
=
k
break
if
pid
<=
0
:
# If we didn't find anything, go to the OS. Otherwise,
# handle waiting
return
_waitpid
(
pid
,
options
)
if
pid
in
_watched_children
:
# yes, we're watching it
...
...
greentest/test__monkey_sigchld.py
View file @
b05ee3d2
import
errno
import
os
import
sys
#os.environ['GEVENT_NOWAITPID'] = 'True'
...
...
@@ -34,6 +35,15 @@ if hasattr(signal, 'SIGCHLD'):
with
gevent
.
Timeout
(
1
):
while
awaiting_child
:
gevent
.
sleep
(
0.01
)
# We should now be able to waitpid() for an arbitrary child
wpid
,
status
=
os
.
waitpid
(
-
1
,
os
.
WNOHANG
)
assert
wpid
==
pid
# And a second call should raise ECHILD
try
:
wpid
,
status
=
os
.
waitpid
(
-
1
,
os
.
WNOHANG
)
raise
AssertionError
(
"Should not be able to wait again"
)
except
OSError
as
e
:
assert
e
.
errno
==
errno
.
ECHILD
sys
.
exit
(
0
)
else
:
print
(
"No SIGCHLD, not testing"
)
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