@@ -16,6 +16,7 @@ var restart = null;
16
16
var psTree = require ( 'pstree.remy' ) ;
17
17
var path = require ( 'path' ) ;
18
18
var signals = require ( './signals' ) ;
19
+ const osRelease = require ( 'os' ) . release ( ) ;
19
20
20
21
function run ( options ) {
21
22
var cmd = config . command . raw ;
@@ -312,19 +313,26 @@ function kill(child, signal, callback) {
312
313
}
313
314
314
315
if ( utils . isWindows ) {
316
+ const taskKill = ( ) => {
317
+ try {
318
+ exec ( 'taskkill /pid ' + child . pid + ' /T /F' ) ;
319
+ } catch ( e ) {
320
+ utils . log . error ( "Could not shutdown sub process cleanly" ) ;
321
+ }
322
+ }
315
323
316
324
// We are handling a 'SIGKILL' POSIX signal under Windows the
317
325
// same way it is handled on a UNIX system: We are performing
318
326
// a hard shutdown without waiting for the process to clean-up.
319
- if ( signal === 'SIGKILL' ) {
327
+ if ( signal === 'SIGKILL' || osRelease < 10 ) {
320
328
321
329
debug ( 'terminating process group by force: %s' , child . pid ) ;
322
330
323
331
// We are using the taskkill utility to terminate the whole
324
332
// process group ('/t') of the child ('/pid') by force ('/f').
325
333
// We need to end all sub processes, because the 'child'
326
334
// process in this context is actually a cmd.exe wrapper.
327
- exec ( `taskkill /f /t /pid ${ child . pid } ` ) ;
335
+ taskKill ( ) ;
328
336
callback ( ) ;
329
337
return ;
330
338
}
@@ -357,9 +365,13 @@ function kill(child, signal, callback) {
357
365
// Therefore we are using 'start' to create a new cmd.exe context.
358
366
// The '/min' option hides the new terminal window and the '/wait'
359
367
// option lets the process wait for the command to finish.
360
- execSync (
361
- `start "windows-kill" /min /wait "${ windowsKill } " -SIGINT ${ processId } `
362
- ) ;
368
+ try {
369
+ execSync (
370
+ `start "windows-kill" /min /wait "${ windowsKill } " -SIGINT ${ processId } `
371
+ ) ;
372
+ } catch ( e ) {
373
+ taskKill ( ) ;
374
+ }
363
375
callback ( ) ;
364
376
365
377
} else {
0 commit comments