Skip to content
Snippets Groups Projects
Commit 86524a70 authored by Bryan O'Sullivan's avatar Bryan O'Sullivan
Browse files

worker: fix a race in SIGINT handling

This is almost impossible to trigger due to the tiny time window involved.
parent d1a2b086
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,8 @@
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:
......@@ -78,6 +80,7 @@
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 @@
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment