Closed
Description
Platform
- { Windows 10 } windows
- { 5.6.3 }
Bug description
When trying to kill a process and failing with "Access Denied" through the Process.kill method, psutil will not throw an exception if the returned handle doesn't have the requested permission.
The bug is in psutil_proc_kill
in _psutil_windows.c
. The current flow is:
- OpenProcess with PROCESS_TERMINATE
- TerminateProcess
- if TerminateProcess failed with access denied - do nothing.
Unfortunately, a valid handle can return from OpenProcess without the PROCESS_TERMINATE access right.
This might happen if the process is protected by windows or an anti-malware program.
This behavior was added to solve #1099.
Reproduce
On a computer with eset installed:
for process in psutil.process_iter():
if process.name() == "eguiProxy.exe":
print("killing")
process.kill()