Fix waitpid() call on python 3.8
This commit is contained in:
parent
bf6c90a69a
commit
cc3c7b0286
@ -353,10 +353,11 @@ def main(args: List[str] = sys.argv) -> None:
|
|||||||
es = str(e).replace('\n', ' ')
|
es = str(e).replace('\n', ' ')
|
||||||
output_buf += f'ERR:{es}\n'.encode()
|
output_buf += f'ERR:{es}\n'.encode()
|
||||||
else:
|
else:
|
||||||
child_id = len(child_id_map) + 1
|
if os.getpid() == self_pid:
|
||||||
child_id_map[child_id] = child_pid
|
child_id = len(child_id_map) + 1
|
||||||
child_ready_fds[child_id] = write_fd
|
child_id_map[child_id] = child_pid
|
||||||
output_buf += f'CHILD:{child_id}:{child_pid}\n'.encode()
|
child_ready_fds[child_id] = write_fd
|
||||||
|
output_buf += f'CHILD:{child_id}:{child_pid}\n'.encode()
|
||||||
finally:
|
finally:
|
||||||
if os.getpid() == self_pid:
|
if os.getpid() == self_pid:
|
||||||
os.close(read_fd)
|
os.close(read_fd)
|
||||||
@ -404,6 +405,10 @@ def main(args: List[str] = sys.argv) -> None:
|
|||||||
pid, exit_status = os.waitpid(-1, os.WNOHANG)
|
pid, exit_status = os.waitpid(-1, os.WNOHANG)
|
||||||
except ChildProcessError:
|
except ChildProcessError:
|
||||||
break
|
break
|
||||||
|
# a zero return means there is at least one child process
|
||||||
|
# existing and no exit status is available
|
||||||
|
if pid == 0:
|
||||||
|
break
|
||||||
matched_child_id = -1
|
matched_child_id = -1
|
||||||
for child_id, child_pid in child_id_map.items():
|
for child_id, child_pid in child_id_map.items():
|
||||||
if child_pid == pid:
|
if child_pid == pid:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user