STINNER Victor <vstin...@python.org> added the comment:

While there was no strong agreement on my change, Nathaniel and Giampaolo said 
that it should not harm to merge it :-) So I merged my change.

It has been said multiple times: my change doesn't fully close the race 
condition. It only reduces the risk that it happens. I rephrased my change to 
mention that there is still room for the race condition and that polling only 
*reduces* the risk, it doesn't fully fix the race condition.

--

Changing locking can help. But I'm not sure that it covers *all* cases. For 
example, what if another function calls os.waitpid() directly for whatever 
reason and the process completed? The pid recycling issue can also happen in 
this case, no?

Linux pidfd really fix the issue. If someone wants to enhance subprocess to use 
the new os.pidfd_open(), I suggest to open a separated issue.

Another approach is to emulate pidfd in userspace. Giampaolo explains that he 
also compares the process creation time for that (msg356571). I'm not excited 
to workaround OS issue this way. It requires to write platform specific 
get_create_time() code. I would prefer to reuse what the OS provides when 
available: Linux pidfd.

--

This issue title is quite explicit on purpose: "subprocess.Popen.send_signal() 
should poll the process". I now close this issue: send_signal() does now poll 
:-)

Because there is no *strong* consensus on my change, I decided to not backport 
it to stable branches 3.7 and 3.8.

Thanks everyone for this very interesting discussion!

----------
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

_______________________________________
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