Skip to content

Commit 4359b07

Browse files
committed
Update comment about PID reuse race
1 parent 5c29144 commit 4359b07

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Lib/subprocess.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,20 +2125,18 @@ def _wait(self, timeout):
21252125
# Try efficient wait first.
21262126
if self._wait_pidfd(timeout) or self._wait_kqueue(timeout):
21272127
# Process is gone. At this point os.waitpid(pid, 0)
2128-
# should return immediately, but in rare races
2129-
# another thread or signal handler may have already
2130-
# reaped the PID. os.waitpid(pid, WNOHANG) ensures
2131-
# we attempt a non-blocking reap safely without
2132-
# blocking indefinitely.
2128+
# should return immediately, but in rare races the
2129+
# PID may have been reused.
2130+
# os.waitpid(pid, WNOHANG) ensures we attempt a
2131+
# non-blocking reap without blocking indefinitely.
21332132
with self._waitpid_lock:
21342133
if self.returncode is not None:
21352134
return self.returncode
21362135
(pid, sts) = self._try_wait(os.WNOHANG)
21372136
assert pid == self.pid or pid == 0
21382137
if pid == self.pid:
21392138
self._handle_exitstatus(sts)
2140-
return self.returncode
2141-
return None
2139+
return self.returncode
21422140

21432141
# Enter a busy loop if we have a timeout. This busy loop was
21442142
# cribbed from Lib/threading.py in Thread.wait() at r71065.

0 commit comments

Comments
 (0)