Skip to content

process: process.kill() and signals on Windows #12378

@vsemozhetbyt

Description

@vsemozhetbyt
  • Version: many
  • Platform: Windows 7 x64
  • Subsystem: process

The doc states:

Note: Windows does not support sending signals, but Node.js offers some emulation with process.kill(), and ChildProcess.kill().

WRT supporting signals on Windows, the doc makes only this remark:

SIGTERM is not supported on Windows, it can be listened on.

As for the rest, process.kill() behavior on Windows is somehow confusing and hazardous. A test file with just this line:

process.kill(process.pid, SIGNAL_NAME_MENTIONED_IN_THE_DOC);

gives three types of results.

  1. SIGTERM, SIGINT, SIGKILL (despite the doc note wrt SIGTERM) — silently exit.
  2. SIGUSR1, SIGPIPE, SIGSTOP, SIGBUS — throw this error:
internal/process.js:184
        throw new Error(`Unknown signal: ${sig}`);
        ^

Error: Unknown signal: SIGUSR1
    at process.kill (internal/process.js:184:15)
    at Object.<anonymous> (...\test.js:5:9)
    at Module._compile (module.js:607:30)
    at Object.Module._extensions..js (module.js:618:10)
    at Module.load (module.js:516:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.runMain (module.js:643:10)
    at run (bootstrap_node.js:441:7)
    at startup (bootstrap_node.js:144:9)
  1. SIGHUP, SIGBREAK, SIGWINCH, SIGFPE, SIGSEGV, SIGILL — throw this error:
internal/process.js:190
      throw errnoException(err, 'kill');
      ^

Error: kill ENOSYS
    at exports._errnoException (util.js:1057:11)
    at process.kill (internal/process.js:190:13)
    at Object.<anonymous> (...\test.js:6:9)
    at Module._compile (module.js:607:30)
    at Object.Module._extensions..js (module.js:618:10)
    at Module.load (module.js:516:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.runMain (module.js:643:10)
    at run (bootstrap_node.js:441:7)

As with this issue, I am not sure, if this is a Node.js or libuv domain. Also I am not sure if this should be addressed in code or in docs. So just reporting for extra precaution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.processIssues and PRs related to the 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