Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions psutil/_pswindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,13 @@ def convert_oserror(exc, pid=None, name=None):
return AccessDenied(pid=pid, name=name)
if isinstance(exc, ProcessLookupError):
return NoSuchProcess(pid=pid, name=name)
if getattr(exc, "winerror", None) == 87:
# os.kill(pid, CTRL_C_EVENT / CTRL_BREAK_EVENT) can raise this
# (WinError 87, "the parameter is incorrect") when the process
# terminates on its own right before the signal is sent.
# See: https://github.com/giampaolo/psutil/issues/2519
msg = f"process {pid} disappeared before the signal could be sent"
return NoSuchProcess(pid=pid, name=name, msg=msg)
raise exc


Expand Down
Loading