[New-bugs-announce] [issue30589] With forkserver, Process.exitcode does not get signal number
Antoine Pitrou
report at bugs.python.org
Wed Jun 7 11:21:05 EDT 2017
New submission from Antoine Pitrou:
The documentation for multiprocessing.exitcode says:
"""
The child’s exit code. This will be None if the process has not yet terminated. A negative value -N indicates that the child was terminated by signal N.
"""
This is true for the "fork" method, but not "forkserver" where a child terminated by a signal will get an exitcode of 255. This is because forkserver relies on the child writing its own exit code in a pipe, which obviously doesn't work if it was killed (255 is simply a fallback value).
See forkserver's Popen.poll():
def poll(self, flag=os.WNOHANG):
if self.returncode is None:
from multiprocessing.connection import wait
timeout = 0 if flag == os.WNOHANG else None
if not wait([self.sentinel], timeout):
return None
try:
self.returncode = forkserver.read_unsigned(self.sentinel)
except (OSError, EOFError):
# The process ended abnormally perhaps because of a signal
self.returncode = 255
return self.returncode
----------
components: Library (Lib)
messages: 295343
nosy: davin, pitrou, sbt
priority: normal
severity: normal
status: open
title: With forkserver, Process.exitcode does not get signal number
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30589>
_______________________________________
More information about the New-bugs-announce
mailing list