Skip to content

Commit

Permalink
fix: add support for hard shutdown on SIGKILL (remy#1720)
Browse files Browse the repository at this point in the history
This commit adds back the hard shutdown behaviour under Windows
as an opt-in: If the --signal option is "SIGKILL" nodemon will
terminate the process group by force without waiting for the
process to clean-up. This matches a SIGKILL on a UNIX system.
  • Loading branch information
countzero committed May 9, 2021
1 parent 50aee8d commit f7c6e0d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/monitor/run.js
Expand Up @@ -313,6 +313,22 @@ function kill(child, signal, callback) {

if (utils.isWindows) {

// We are handling a 'SIGKILL' POSIX signal under Windows the
// same way it is handled on a UNIX system: We are performing
// a hard shutdown without waiting for the process to clean-up.
if (signal === 'SIGKILL') {

debug('terminating process group by force: %s', child.pid);

// We are using the taskkill utility to terminate the whole
// process group ('/t') of the child ('/pid') by force ('/f').
// We need to end all sub processes, because the 'child'
// process in this context is actually a cmd.exe wrapper.
exec(`taskkill /f /t /pid ${child.pid}`);
callback();
return;
}

// We are using the Windows Management Instrumentation Command-line
// (wmic.exe) to resolve the sub-child process identifier, because the
// 'child' process in this context is actually a cmd.exe wrapper.
Expand Down

0 comments on commit f7c6e0d

Please sign in to comment.