[PATCH 2 of 3] worker: fix a race in SIGINT handling
Bryan O'Sullivan
bos at serpentine.com
Tue Feb 19 12:29:14 CST 2013
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1361297550 28800
# Node ID 9ef52f0a93a0cba939742743ff59e4c2a2463fab
# Parent aa2394d75dcc1fb33f3f548013874acdfbaf845f
worker: fix a race in SIGINT handling
This is almost impossible to trigger due to the tiny time window involved.
diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -75,9 +75,12 @@ def worker(ui, costperarg, func, statica
def _posixworker(ui, func, staticargs, args):
rfd, wfd = os.pipe()
workers = _numworkers(ui)
+ oldhandler = signal.getsignal(signal.SIGINT)
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
for pargs in partition(args, workers):
pid = os.fork()
if pid == 0:
+ signal.signal(signal.SIGINT, oldhandler)
try:
os.close(rfd)
for i, item in func(*(staticargs + (pargs,))):
@@ -87,8 +90,6 @@ def _posixworker(ui, func, staticargs, a
os._exit(255)
os.close(wfd)
fp = os.fdopen(rfd, 'rb', 0)
- oldhandler = signal.getsignal(signal.SIGINT)
- signal.signal(signal.SIGINT, signal.SIG_IGN)
def cleanup():
# python 2.4 is too dumb for try/yield/finally
signal.signal(signal.SIGINT, oldhandler)
More information about the Mercurial-devel
mailing list