Skip to content

subprocess.kill should ignore signal argument on Windows #42923

Description

@fasttime

Version

v18.0.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

child_process

What steps will reproduce the bug?

The documentation about subprocess.kill([signal]) says:

On Windows, where POSIX signals do not exist, the signal argument will be
ignored, and the process will be killed forcefully and abruptly (similar to
'SIGKILL').

This does not seem to match the current behavior, where the signal argument is not ignored on Windows, and it can lead in fact to different results. A minimal repro:

// test.mjs - Run on Windows

import { spawn } from 'child_process';

spawn(process.execPath, ['-v']).kill('SIGKILL'); // ok
spawn(process.execPath, ['-v']).kill('SIGHUP'); // throws ENOSYS

How often does it reproduce? Is there a required condition?

Always on Windows

What is the expected behavior?

If the documentation is right, invoking kill('SIGHUP') on a subprocess on Windows should work exactly like kill('SIGKILL').

What do you see instead?

The signal argument is not currently ignored on Windows. I can't decide if this behavior is intended and the documentation is wrong or if the documentation is right and the behavior is incorrect.

Additional information

If someone could clarify me about the expectations of running subprocess.kill on Windows, I would be glad to submit a PR to fix the code or the documentation.

Activity

  1. added
    child_processIssues and PRs related to the child_process subsystem.
    windowsIssues and PRs related to the Windows platform.
    on Apr 30, 2022
  2. fabiospampinato commented on Dec 9, 2023

    @fabiospampinato

    This seems a fairly significant issue, in the sense that anybody that is triggering a signal with process.kill without knowing this issue is probably doing it in a problematic way for Windows.

  3. added a commit that references this issue on Nov 26, 2024
  4. added a commit that references this issue on Dec 10, 2024
  5. added a commit that references this issue on Jan 5, 2025
  6. 3 remaining items

  7. added a commit that references this issue on May 6, 2025
  8. added a commit that references this issue on May 14, 2025
  9. ehmicky commented on Oct 26, 2025

    @ehmicky

    @StefanStojanovic Thanks for fixing subprocess.kill(0)!

    However, subprocess.kill('SIGWINCH') is still having this problem, as mentioned in earlier messages from this issue. Therefore I believe this issue should remain open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions