If I do child_process.exec('mycommand', { timeout: 5000 }, callback)
, I don't know if the resulting error is caused by a timeout or some other reason. Is there a way to determine whether the failure was caused by the { timeout: 5000 }
option passed to child_process
?
There's only one way which may not be quite reliable.
So be careful when you use it for your needs
How it works:
SIGTERM
signal unless you override in the options {killSignal : 'SIGINT'}cb(err,stdout,stderr)
is called by populating err.code
to null
and err.signal
to SIGTERM
or whatever it isSo you can check for err.signal
in the callback. And again this is not quite reliable as you can kill the child process from task manager or using shell's kill command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With