[PATCH STABLE] worker: wait worker pid explicitly
yuya at tcha.org
Sat Jul 23 10:39:54 EDT 2016
On Fri, 22 Jul 2016 20:50:48 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1469216267 -3600
> # Fri Jul 22 20:37:47 2016 +0100
> # Node ID 74d799c4781183b539aedd93530f0e5fa06839cc
> # Parent d3df009ab1175a6792549b51ae66486dd98f398b
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 74d799c47811
> worker: wait worker pid explicitly
> Before this patch, waitforworkers uses os.wait() to collect child workers, and
> only wait len(pids) processes. This can have serious issues if other code
> spawns new processes and does not reap them: 1. worker.py may get wrong exit
> code and kill innocent workers. 2. worker.py may continue without waiting for
> all workers to complete.
> This patch fixes the issue by using waitpid to wait worker pid explicitly.
> diff --git a/mercurial/worker.py b/mercurial/worker.py
> --- a/mercurial/worker.py
> +++ b/mercurial/worker.py
> @@ -112,8 +112,8 @@ def _posixworker(ui, func, staticargs, a
> if err.errno != errno.ESRCH:
> def waitforworkers():
> - for _pid in pids:
> - st = _exitstatus(os.wait())
> + for pid in pids:
> + st = _exitstatus(os.waitpid(pid, 0))
New implementation can't detect failures ASAP, which is what 9955fc5ee24b
tried to solve.
Somewhat related, maybe we can handle this issue by worker-to-master pipe?
More information about the Mercurial-devel