Nathaniel Smith <n...@pobox.com> added the comment:

Hmm, you know, on further thought, it is actually possible to close this race 
for real, without pidfd.

What you do is split 'wait' into two parts: first it waits for me process to 
become reapable without actually reaping it. On Linux you can do this with 
waitid+WNOWAIT. On kqueue platforms you can do it with kqueue.

Then, you take a lock, and use it to atomically call waitpid/waitid to reap the 
process + update self.returncode to record that you've done so.

In send_signal, we use the same lock to atomically check whether the process 
has been reaped, and then send the signal if it hasn't.

That doesn't fix your test, but it does fix the race condition: as long as 
users only interact with the process through the Popen API, it guarantees that 
send_signal will never rather the wrong process.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38630>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to