tapjs / foreground-child

Run a child as if it's the foreground process. Give it stdio. Exit when it exits.
http://tapjs.github.io/foreground-child/
ISC License
39 stars 14 forks source link

SIGHUP is not supported on Windows #49

Closed fasttime closed 5 months ago

fasttime commented 2 years ago

Windows 10 Node.js 18.0.0 foreground-child 2.0.0


When the parent process terminates, it sends a SIGHUP signal to kill the child:

https://github.com/tapjs/foreground-child/blob/a6704d99ffa6d379ba3b9599ea2df9bffbedd70c/index.js#L58

This is failing on Windows, apparently because SIGHUP is not supported:

     Error: kill ENOSYS
      at ChildProcess.kill (node:internal/child_process:501:13)

The error message is not helpful, but a comment line in the source code of child_process explains it:

https://github.com/nodejs/node/blob/v18.0.0/lib/internal/child_process.js#L500-L501

      /* The underlying platform doesn't support this signal. */
      throw errnoException(err, 'kill');

Maybe send SIGTERM on Windows and SIGHUP on other platforms?

isaacs commented 1 year ago

Fixed by https://github.com/tapjs/foreground-child/pull/52 (along with many other things that made this module much more flaky and hard to work with).