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}`))
}
})
let exited = false
subprocess.on('exit', () => exited = true)
subprocess.on('error', reject)
process.on('exit', () => {
if (!exited) {
const kill = () => {
process.stderr.write(`Killing ${this.command} ${this.args.join(' ')}\n`)
subprocess.kill()
}
})
process.on('exit', kill)
subprocess.on('exit', () => process.removeListener('exit', kill))
})
}
}