nl_tokens: Spawn a child process with the canceller function .
pl_tokens: function spawnCancelableChild ( bin , args , option ) { let innerCancel = null ; let isCanceled = false ; const canceller = function ( ) { if ( isCanceled ) { return ; } isCanceled = true ; if ( typeof innerCancel === 'function' ) { innerCancel ( ) ; } } ; const process = new Promise ( function ( resolve , reject ) { if ( isCanceled ) { reject ( ) ; return ; } console . log ( 'spawn: ' + bin + ' ' + args . join ( ' ' ) ) ; const proc = childProcess . spawn ( bin , args , option ) ; innerCancel = function ( ) { proc . kill ( 'SIGINT' ) ; } ; proc . on ( 'exit' , function ( status ) { resolve ( <mask> ) ; } ) ; } ) ; return { canceller , process , } ; }