bpo-38630: Fix subprocess.Popen.send_signal() race condition (GH-16984)

On Unix, subprocess.Popen.send_signal() now polls the process status.
Polling reduces the risk of sending a signal to the wrong process if
the process completed, the Popen.returncode attribute is still None,
and the pid has been reassigned (recycled) to a new different
process.
This commit is contained in:
Victor Stinner 2020-01-15 17:38:55 +01:00 committed by GitHub
parent ed154c387e
commit e85a305503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 3 deletions

View file

@ -774,6 +774,8 @@ Instances of the :class:`Popen` class have the following methods:
Sends the signal *signal* to the child.
Do nothing if the process completed.
.. note::
On Windows, SIGTERM is an alias for :meth:`terminate`. CTRL_C_EVENT and