From patchwork Sat Nov 12 03:11:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7, of, 8, V4] worker: add a SIGCHLD handler to collect worker immediately From: Jun Wu X-Patchwork-Id: 17513 Message-Id: <7492186538a69cdfad28.1478920298@x1c> To: Date: Sat, 12 Nov 2016 03:11:38 +0000 # HG changeset patch # User Jun Wu # Date 1478920042 0 # Sat Nov 12 03:07:22 2016 +0000 # Node ID 7492186538a69cdfad28cb93093d7f7077942ca3 # Parent 596cee9d5c12dcfa2d272b5441d5060a26a6440c # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r 7492186538a6 worker: add a SIGCHLD handler to collect worker immediately As planned by previous patches, add a SIGCHLD handler to get notifications about worker exits, and deals with worker failure immediately. diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -126,8 +126,12 @@ def _posixworker(ui, func, staticargs, a problem[0] = st killworkers() + def sigchldhandler(signum, frame): + waitforworkers(blocking=False) + oldchldhandler = signal.signal(signal.SIGCHLD, sigchldhandler) for pargs in partition(args, workers): pid = os.fork() if pid == 0: signal.signal(signal.SIGINT, oldhandler) + signal.signal(signal.SIGCHLD, oldchldhandler) try: os.close(rfd) @@ -147,4 +151,5 @@ def _posixworker(ui, func, staticargs, a signal.signal(signal.SIGINT, oldhandler) t.join() + signal.signal(signal.SIGCHLD, oldchldhandler) status = problem[0] if status: