Reputation: 767
Is it possible to start a process out of node, which is not a child process from the node instance but a system process? If i use child_process, new processes are included in the father process. The problem is, that all other processes will be killed, if the father process is canceled. I want to run the new processes instead the father process is killed.
Upvotes: 1
Views: 155
Reputation: 26124
Give child.unref()
a try. According to the node.js documentation:
If the detached option is set, the child process will be made the leader of a new process group. This makes it possible for the child to continue running after the parent exits.
By default, the parent will wait for the detached child to exit. To prevent the parent from waiting for a given child, use the child.unref() method, and the parent's event loop will not include the child in its reference count.
Emphasis mine. So knowing that, you can also pass in true
to the detached
option in the options hash when forking:
var child = spawn('prg', [], {
detached: true,
stdio: [ 'ignore', out, err ]
});
Upvotes: 1