Skip to content

Behaviour of os.kill() on Windows may be misunderstood #125298

@honorasm

Description

@honorasm

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 with Python 3.12.6 on Windows 10 Education Edition version 22H2 amd64 will result in an error.

Test code:

import os, signal
proc_handle = os.spawnl(os.P_NOWAIT, r'C:\Windows\notepad.exe', 'notepad.exe')
os.kill(proc_handle, signal.SIGTERM)

Error message:

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsdocsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions