@@ -678,7 +678,9 @@ export class ToolRunner extends events.EventEmitter {
678678 if ( fileStream ) {
679679 fileStream . write ( data ) ;
680680 }
681- cp . stdin ?. write ( data ) ;
681+ if ( ! cp . stdin ?. destroyed ) {
682+ cp . stdin ?. write ( data ) ;
683+ }
682684 } catch ( err ) {
683685 this . _debug ( 'Failed to pipe output of ' + toolPathFirst + ' to ' + toolPath ) ;
684686 this . _debug ( toolPath + ' might have exited due to errors prematurely. Verify the arguments passed are valid.' ) ;
@@ -1180,18 +1182,18 @@ export class ToolRunner extends events.EventEmitter {
11801182 state . CheckComplete ( ) ;
11811183 } ) ;
11821184
1183- cp . on ( 'exit' , ( code : number , signal : any ) => {
1185+ cp . on ( 'exit' , ( code : number , signal : number | NodeJS . Signals ) => {
11841186 state . processExitCode = code ;
11851187 state . processExited = true ;
1186- this . _debug ( `Exit code ${ code } received from tool '${ this . toolPath } '` ) ;
1188+ this . _debug ( `STDIO streams have closed and received exit code ${ code } and signal ${ signal } for tool '${ this . toolPath } '` ) ;
11871189 state . CheckComplete ( )
11881190 } ) ;
11891191
1190- cp . on ( 'close' , ( code : number , signal : any ) => {
1192+ cp . on ( 'close' , ( code : number , signal : number | NodeJS . Signals ) => {
11911193 state . processExitCode = code ;
11921194 state . processExited = true ;
11931195 state . processClosed = true ;
1194- this . _debug ( `STDIO streams have closed for tool '${ this . toolPath } '` )
1196+ this . _debug ( `STDIO streams have closed and received exit code ${ code } and signal ${ signal } for tool '${ this . toolPath } '` ) ;
11951197 state . CheckComplete ( ) ;
11961198 } ) ;
11971199
@@ -1312,18 +1314,18 @@ export class ToolRunner extends events.EventEmitter {
13121314 state . CheckComplete ( ) ;
13131315 } ) ;
13141316
1315- cp . on ( 'exit' , ( code : number , signal : any ) => {
1317+ cp . on ( 'exit' , ( code : number , signal : number | NodeJS . Signals ) => {
13161318 state . processExitCode = code ;
13171319 state . processExited = true ;
1318- this . _debug ( `Exit code ${ code } received from tool '${ this . toolPath } '` ) ;
1320+ this . _debug ( `STDIO streams have closed and received exit code ${ code } and signal ${ signal } for tool '${ this . toolPath } '` ) ;
13191321 state . CheckComplete ( )
13201322 } ) ;
13211323
1322- cp . on ( 'close' , ( code : number , signal : any ) => {
1324+ cp . on ( 'close' , ( code : number , signal : number | NodeJS . Signals ) => {
13231325 state . processExitCode = code ;
13241326 state . processExited = true ;
13251327 state . processClosed = true ;
1326- this . _debug ( `STDIO streams have closed for tool '${ this . toolPath } '` )
1328+ this . _debug ( `STDIO streams have closed and received exit code ${ code } and signal ${ signal } for tool '${ this . toolPath } '` ) ;
13271329 state . CheckComplete ( ) ;
13281330 } ) ;
13291331
@@ -1374,9 +1376,10 @@ export class ToolRunner extends events.EventEmitter {
13741376 * Used to close child process by sending SIGNINT signal.
13751377 * It allows executed script to have some additional logic on SIGINT, before exiting.
13761378 */
1377- public killChildProcess ( ) : void {
1379+ public killChildProcess ( signal : number | NodeJS . Signals = "SIGTERM" ) : void {
13781380 if ( this . childProcess ) {
1379- this . childProcess . kill ( ) ;
1381+ this . _debug ( `[killChildProcess] Signal ${ signal } received` ) ;
1382+ this . childProcess . kill ( signal ) ;
13801383 }
13811384 }
13821385}
0 commit comments