comparison mercurial/worker.py @ 30424:f2d13eb85198

worker: kill workers after all zombie processes are reaped Since we now wait child processes in non-blocking way (changed by 7bc25549e084 and e8fb03cfbbde), we don't have to kill them in the middle of the waitpid() loop. This change will help solving a possible race of waitpid()-pids.discard() sequence and another SIGCHLD. waitforworkers() is called by cleanup(), in which case we do killworkers() beforehand so we can remove killworkers() from waitforworkers().
author Yuya Nishihara <yuya@tcha.org>
date Thu, 17 Nov 2016 21:08:58 +0900
parents 237b2883cbd8
children 03f7aa2bd0e3
comparison
equal deleted inserted replaced
30423:237b2883cbd8 30424:f2d13eb85198
117 if p: 117 if p:
118 pids.remove(p) 118 pids.remove(p)
119 st = _exitstatus(st) 119 st = _exitstatus(st)
120 if st and not problem[0]: 120 if st and not problem[0]:
121 problem[0] = st 121 problem[0] = st
122 killworkers()
123 def sigchldhandler(signum, frame): 122 def sigchldhandler(signum, frame):
124 waitforworkers(blocking=False) 123 waitforworkers(blocking=False)
124 if problem[0]:
125 killworkers()
125 oldchldhandler = signal.signal(signal.SIGCHLD, sigchldhandler) 126 oldchldhandler = signal.signal(signal.SIGCHLD, sigchldhandler)
126 for pargs in partition(args, workers): 127 for pargs in partition(args, workers):
127 pid = os.fork() 128 pid = os.fork()
128 if pid == 0: 129 if pid == 0:
129 signal.signal(signal.SIGINT, oldhandler) 130 signal.signal(signal.SIGINT, oldhandler)