Mercurial > public > mercurial-scm > hg
comparison mercurial/worker.py @ 30425:03f7aa2bd0e3
worker: discard waited pid by anyone who noticed it first
This makes sure all waited pids are removed before calling killworkers()
even if waitpid()-pids.discard() sequence is interrupted by another SIGCHLD.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 17 Nov 2016 20:57:09 +0900 |
parents | f2d13eb85198 |
children | 86cd09bc13ba |
comparison
equal
deleted
inserted
replaced
30424:f2d13eb85198 | 30425:03f7aa2bd0e3 |
---|---|
109 break | 109 break |
110 except OSError as e: | 110 except OSError as e: |
111 if e.errno == errno.EINTR: | 111 if e.errno == errno.EINTR: |
112 continue | 112 continue |
113 elif e.errno == errno.ECHILD: | 113 elif e.errno == errno.ECHILD: |
114 break # ignore ECHILD | 114 # child would already be reaped, but pids yet been |
115 # updated (maybe interrupted just after waitpid) | |
116 pids.discard(pid) | |
117 break | |
115 else: | 118 else: |
116 raise | 119 raise |
117 if p: | 120 if p: |
118 pids.remove(p) | 121 pids.discard(p) |
119 st = _exitstatus(st) | 122 st = _exitstatus(st) |
120 if st and not problem[0]: | 123 if st and not problem[0]: |
121 problem[0] = st | 124 problem[0] = st |
122 def sigchldhandler(signum, frame): | 125 def sigchldhandler(signum, frame): |
123 waitforworkers(blocking=False) | 126 waitforworkers(blocking=False) |