worker: discard waited pid by anyone who noticed it first
authorYuya Nishihara <yuya@tcha.org>
Thu, 17 Nov 2016 20:57:09 +0900
changeset 30425 03f7aa2bd0e3
parent 30424 f2d13eb85198
child 30426 605e3b126d46
worker: discard waited pid by anyone who noticed it first This makes sure all waited pids are removed before calling killworkers() even if waitpid()-pids.discard() sequence is interrupted by another SIGCHLD.
mercurial/worker.py
--- a/mercurial/worker.py	Thu Nov 17 21:08:58 2016 +0900
+++ b/mercurial/worker.py	Thu Nov 17 20:57:09 2016 +0900
@@ -111,11 +111,14 @@
                     if e.errno == errno.EINTR:
                         continue
                     elif e.errno == errno.ECHILD:
-                        break # ignore ECHILD
+                        # child would already be reaped, but pids yet been
+                        # updated (maybe interrupted just after waitpid)
+                        pids.discard(pid)
+                        break
                     else:
                         raise
             if p:
-                pids.remove(p)
+                pids.discard(p)
                 st = _exitstatus(st)
             if st and not problem[0]:
                 problem[0] = st