Process.killChildProcess()

Gracefully kill a child process.

This uses the `.kill()` instance method from Node.js core. By default, SIGTERM is used.

Usage

Hover over inputs/exits for more info.

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) {

 

},

});

Inputs

childProcess required

The child process to kill.

'==='
forceIfNecessary

If set, then force the child process to exit if it cannot be killed gracefully (e.g. because it is already dead).

false
maxMsToWait

The maximum number of miliseconds to wait for the child process to shut down gracefully.

500

Exits

error

An unexpected error occurred.

invalidChildProcess

The specified value is not a valid child process instance.

couldNotKill

The child process could not be killed gracefully.

success

OK.

false