*I use Node.js version 0.10.28*
- I want to just kill child process, and keep master process. But when I
run process.exit(0); in child.js. then the master process also has been
killed. How should I handle this?
*My Code*
*Master.js*
var cp = require('child_process'),
fork = cp.fork('./server/rpc/download.js');
fork.send({ zip: '111' });
fork.on('message', function(msg){
if(msg.status === 'done') {
fork.kill('SIGTERM');
}
});
fork.onUnexpectedExit = function (code, signal) {
process.exit(1);
};
fork.on("exit", fork.onUnexpectedExit);
*Child.js*
process.on('message', function(m) {
if(m.zip === '111' ) {
//Do something logic
process.send({status: 'done'});
}
});
process.on('uncaughtException',function(err){
console.log("fetch.js: " + err.message + "\n" + err.stack + "\n
Stopping background timer");
});
// SIGTERM AND SIGINT will trigger the exit event.
process.once("SIGTERM", function () {
console.log('SIGTERM');
process.exit(0);
});
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/69463d6a-7f9e-4cc2-8a46-c6b2b04a72e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.