Skip to content

Commit 3c156a9

Browse files
committed
Add comment
1 parent 4eac42f commit 3c156a9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/subprocess.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,12 @@ def _wait(self, timeout):
21252125
if timeout is not None:
21262126
# Try efficient wait first.
21272127
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.
21282134
with self._waitpid_lock:
21292135
if self.returncode is not None:
21302136
return self.returncode

0 commit comments

Comments
 (0)