Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ForkedFunc to handle hard exit(0) #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions py/_process/forkedfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ def waitfinish(self, waiter=os.waitpid):
exitstatus = 0
signal = systemstatus & 0x7f
if not exitstatus and not signal:
retval = self.RETVAL.open('rb')
retvalf = self.RETVAL.open('rb')
try:
retval_data = retval.read()
retval_data = retvalf.read()
retval = marshal.loads(retval_data)
except:
retval = None
finally:
retval.close()
retval = marshal.loads(retval_data)
retvalf.close()
else:
retval = None
stdout = self.STDOUT.read()
Expand Down
9 changes: 9 additions & 0 deletions testing/process/test_forkedfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def func():
assert not result.out
assert not result.err

def test_exit0():
def exit0():
os._exit(0)
result = py.process.ForkedFunc(exit0).waitfinish()
assert result.exitstatus == 0
assert result.signal == 0
assert not result.out
assert not result.err

def test_execption_in_func():
def fun():
raise ValueError(42)
Expand Down