//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) });