Add log message when killing subprocess

This commit is contained in:
Jerko Steiner 2019-08-02 09:21:38 +07:00
parent 9d35984033
commit d2a9d6faf6

View File

@ -36,15 +36,14 @@ export class Subprocess {
reject(new Error(`"${this.command}" exited with code ${code}`)) reject(new Error(`"${this.command}" exited with code ${code}`))
} }
}) })
let exited = false
subprocess.on('exit', () => exited = true)
subprocess.on('error', reject) subprocess.on('error', reject)
process.on('exit', () => { const kill = () => {
if (!exited) { process.stderr.write(`Killing ${this.command} ${this.args.join(' ')}\n`)
subprocess.kill() subprocess.kill()
} }
}) process.on('exit', kill)
subprocess.on('exit', () => process.removeListener('exit', kill))
}) })
} }
} }