Gracefully kill a child process.
This uses the `.kill()` instance method from Node.js core. By default, SIGTERM is used.
var Process = require('machinepack-process');
// Gracefully kill a child process.
Process.killChildProcess({
childProcess: '===',
forceIfNecessary: false,
maxMsToWait: 500,
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// The specified value is not a valid child process instance.
invalidChildProcess: function () {
},
// The child process could not be killed gracefully.
couldNotKill: function () {
},
// OK.
success: function (result) {
},
});
The child process to kill.
'==='
If set, then force the child process to exit if it cannot be killed gracefully (e.g. because it is already dead).
false
The maximum number of miliseconds to wait for the child process to shut down gracefully.
500
An unexpected error occurred.
The specified value is not a valid child process instance.
The child process could not be killed gracefully.
OK.
false