nodejs child process

//Create child process
var thread = require('child_process'); var msg = thread.fork(__dirname + '/child.js',['asdasd']); msg.on('message', function (m) { debugger; console.log('PARENT got message:', m); }); msg.on('close', function () { //3 debugger; }) msg.on('disconnect', function () { //1 debugger; }) msg.on('exit', function () { //2 debugger; }) msg.send('asd'); setTimeout(function () { msg.kill(); }, 5000);

  

child.js

process.on('message', function (m,arr) {
    setInterval(function () {
    process.exit(1);
    },2000)
});

  

 

posted @ 2013-11-05 17:16  高捍得  阅读(361)  评论(0编辑  收藏  举报