worker: allow waitforworkers to be non-blocking
This patch adds a boolean flag to waitforworkers and makes it non-blocking
if set to True.
This is to make it possible that we can reap our workers while keep other
unrelated children untouched, after receiving SIGCHLD.
--- a/mercurial/worker.py Thu Jul 28 20:51:20 2016 +0100
+++ b/mercurial/worker.py Thu Jul 28 20:57:07 2016 +0100
@@ -97,9 +97,11 @@
except OSError as err:
if err.errno != errno.ESRCH:
raise
- def waitforworkers():
+ def waitforworkers(blocking=True):
for pid in pids:
- st = _exitstatus(os.waitpid(pid, 0)[1])
+ p, st = os.waitpid(pid, 0 if blocking else os.WNOHANG)
+ if p:
+ st = _exitstatus(st)
if st and not problem[0]:
problem[0] = st
killworkers()