We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4eac42f commit 3c156a9Copy full SHA for 3c156a9
1 file changed
Lib/subprocess.py
@@ -2125,6 +2125,12 @@ def _wait(self, timeout):
2125
if timeout is not None:
2126
# Try efficient wait first.
2127
if self._wait_pidfd(timeout) or self._wait_kqueue(timeout):
2128
+ # Process is gone. At this point os.waitpid(pid, 0)
2129
+ # should return immediately, but in rare races
2130
+ # another thread or signal handler may have already
2131
+ # reaped the PID. os.waitpid(pid, WNOHANG) ensures
2132
+ # we attempt a non-blocking reap safely without
2133
+ # blocking indefinitely.
2134
with self._waitpid_lock:
2135
if self.returncode is not None:
2136
return self.returncode
0 commit comments