22const { spawn } = require ( "child_process" ) ;
33const { normalize } = require ( "path" ) ;
44
5- const termiateSignals = [ "close" , "exit" , "" ] ;
5+ // 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly.
6+ // We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess
7+ const terminationSignal = [ "close" , "exit" ] ;
68
79function startSubprocess ( ) {
810 return new Promise ( ( res , rej ) => {
9- const proc = spawn ( process . argv . slice ( 2 ) . map ( normalize ) . join ( " " ) , {
11+ const [ command , ...args ] = process . argv . slice ( 2 ) ;
12+ const proc = spawn ( normalize ( command ) , args , {
1013 stdio : [ "pipe" , "pipe" , "pipe" ] ,
1114 shell :
1215 process . platform === "win32" ||
@@ -15,7 +18,7 @@ function startSubprocess() {
1518 proc . stdout . pipe ( process . stdout ) ;
1619 proc . stderr . pipe ( process . stderr ) ;
1720 process . stdin . pipe ( proc . stdin ) ;
18- termiateSignals . forEach ( ( e ) => proc . on ( e , res ) ) ;
21+ terminationSignal . forEach ( ( event ) => proc . on ( event , res ) ) ;
1922 proc . on ( "error" , rej ) ;
2023 } ) ;
2124}
0 commit comments