# HG changeset patch # User Manuel Jacob # Date 2022-05-31 02:18:22 # Node ID dfdf85f37215deab02fb73c6416d4951773f873b # Parent ee4537e365c8ad04f10cfaf058b00f292261b0d5 py3: catch ChildProcessError instead of checking errno == ECHILD diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py --- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -693,9 +693,7 @@ class unixforkingservice: while self._workerpids: try: pid, _status = os.waitpid(-1, options) - except OSError as inst: - if inst.errno != errno.ECHILD: - raise + except ChildProcessError: # no child processes at all (reaped by other waitpid()?) self._workerpids.clear() return diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -186,13 +186,10 @@ def _posixworker(ui, func, staticargs, a p = st = 0 try: p, st = os.waitpid(pid, (0 if blocking else os.WNOHANG)) - except OSError as e: - if e.errno == errno.ECHILD: - # child would already be reaped, but pids yet been - # updated (maybe interrupted just after waitpid) - pids.discard(pid) - else: - raise + except ChildProcessError: + # child would already be reaped, but pids yet been + # updated (maybe interrupted just after waitpid) + pids.discard(pid) if not p: # skip subsequent steps, because child process should # be still running in this case