File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,23 +167,25 @@ def _reg_sigchld(self):
167167
168168 def _sig_chld (self ):
169169 try :
170- try :
171- pid , status = os .waitpid (- 1 , os .WNOHANG )
172- except ChildProcessError :
173- return
174- if pid == 0 :
175- self .call_soon (self ._sig_chld )
176- return
177- elif os .WIFSIGNALED (status ):
178- returncode = - os .WTERMSIG (status )
179- elif os .WIFEXITED (status ):
180- returncode = os .WEXITSTATUS (status )
181- else :
182- self .call_soon (self ._sig_chld )
183- return
184- transp = self ._subprocesses .get (pid )
185- if transp is not None :
186- transp ._process_exited (returncode )
170+ # because of signal coalescing, we must keep calling waitpid() as
171+ # long as we're able to reap a child
172+ while True :
173+ try :
174+ pid , status = os .waitpid (- 1 , os .WNOHANG )
175+ except ChildProcessError :
176+ break
177+ if pid == 0 :
178+ break
179+ elif os .WIFSIGNALED (status ):
180+ returncode = - os .WTERMSIG (status )
181+ elif os .WIFEXITED (status ):
182+ returncode = os .WEXITSTATUS (status )
183+ else :
184+ # shouldn't happen
185+ continue
186+ transp = self ._subprocesses .get (pid )
187+ if transp is not None :
188+ transp ._process_exited (returncode )
187189 except Exception :
188190 logger .exception ('Unknown exception in SIGCHLD handler' )
189191
You can’t perform that action at this time.
0 commit comments