import os, signal
proc_handle = os.spawnl(os.P_NOWAIT, r'C:\Windows\notepad.exe', 'notepad.exe')
os.kill(proc_handle, signal.SIGTERM)
Traceback (most recent call last):
File "C:\Users\John\Documents\Python\os_kill_proc_handle.py", line 3, in <module>
os.kill(proc_handle, signal.SIGTERM)
OSError: [WinError 87] The parameter is incorrect
The latest os.kill() document says “The Windows version of kill() additionally takes process handles to be killed,” but the
kill()function actually does not accept process handles instead of process IDs. Runing the following code withPython 3.12.6onWindows 10 Education Edition version 22H2 amd64will result in an error.Test code:
Error message:
Linked PRs
os.killdescription #125749