[PATCH 5 of 7 V3] worker: add a SIGCHLD handler
Jun Wu
quark at fb.com
Thu Aug 4 14:29:06 EDT 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1469737655 -3600
# Thu Jul 28 21:27:35 2016 +0100
# Node ID d179a66b0b15988687ba9d69c5b76e4464a457eb
# Parent 74a3dd438c5645cc1a685e788d86e70698bfe6c9
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r d179a66b0b15
worker: add a SIGCHLD handler
As planned, we add a SIGCHLD handler to notice and handle child failure
immediately.
diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -110,10 +110,14 @@ def _posixworker(ui, func, staticargs, a
if st and not problem[0]:
problem[0] = st
killworkers()
+ def sigchldhandler(signum, frame):
+ waitforworkers(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)
for i, item in func(*(staticargs + (pargs,))):
@@ -132,6 +136,7 @@ def _posixworker(ui, func, staticargs, a
def cleanup():
signal.signal(signal.SIGINT, oldhandler)
t.join()
+ signal.signal(signal.SIGCHLD, oldchldhandler)
status = problem[0]
if status:
if status < 0:
More information about the Mercurial-devel
mailing list