From patchwork Thu Nov 17 13:20:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,4] worker: discard waited pid by anyone who noticed it first From: Yuya Nishihara X-Patchwork-Id: 17615 Message-Id: <5e9721975f8cda7daea6.1479388802@mimosa> To: mercurial-devel@mercurial-scm.org Date: Thu, 17 Nov 2016 22:20:02 +0900 # HG changeset patch # User Yuya Nishihara # Date 1479383829 -32400 # Thu Nov 17 20:57:09 2016 +0900 # Node ID 5e9721975f8cda7daea6ee0cc6aaad7af5096a08 # Parent 4be342413ddecd0eb6d76c4e5d8bb38fee28061d 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. diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -111,11 +111,14 @@ def _posixworker(ui, func, staticargs, a 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