diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-06-12 13:28:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-12 13:28:19 (GMT) |
commit | dfd5f34634f9c505945e9348b4b799544680a7cf (patch) | |
tree | 153e7ebd65c9c0777ca8a5e8758d3b54783478c4 /Lib/multiprocessing/popen_forkserver.py | |
parent | ced36a993fcfd1c76637119d31c03156a8772e11 (diff) | |
download | cpython-dfd5f34634f9c505945e9348b4b799544680a7cf.zip cpython-dfd5f34634f9c505945e9348b4b799544680a7cf.tar.gz cpython-dfd5f34634f9c505945e9348b4b799544680a7cf.tar.bz2 |
Fix bpo-30589: improve Process.exitcode with forkserver (#1989)
* Fix bpo-30589: improve Process.exitcode with forkserver
When the child is killed, Process.exitcode should return -signum, not 255.
* Add Misc/NEWS
Diffstat (limited to 'Lib/multiprocessing/popen_forkserver.py')
-rw-r--r-- | Lib/multiprocessing/popen_forkserver.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/multiprocessing/popen_forkserver.py b/Lib/multiprocessing/popen_forkserver.py index 222db2d..fa8e574 100644 --- a/Lib/multiprocessing/popen_forkserver.py +++ b/Lib/multiprocessing/popen_forkserver.py @@ -52,7 +52,7 @@ class Popen(popen_fork.Popen): util.Finalize(self, os.close, (self.sentinel,)) with open(w, 'wb', closefd=True) as f: f.write(buf.getbuffer()) - self.pid = forkserver.read_unsigned(self.sentinel) + self.pid = forkserver.read_signed(self.sentinel) def poll(self, flag=os.WNOHANG): if self.returncode is None: @@ -61,8 +61,10 @@ class Popen(popen_fork.Popen): if not wait([self.sentinel], timeout): return None try: - self.returncode = forkserver.read_unsigned(self.sentinel) + self.returncode = forkserver.read_signed(self.sentinel) except (OSError, EOFError): - # The process ended abnormally perhaps because of a signal + # This should not happen usually, but perhaps the forkserver + # process itself got killed self.returncode = 255 + return self.returncode |