node/test/parallel/test-child-process-fork-ref2.js

25 lines
537 B
JavaScript
Raw Normal View History

'use strict';
require('../common');
const fork = require('child_process').fork;
2012-08-01 11:39:14 +00:00
if (process.argv[2] === 'child') {
console.log('child -> call disconnect');
process.disconnect();
setTimeout(function() {
console.log('child -> will this keep it alive?');
process.on('message', function() { });
2012-08-01 11:39:14 +00:00
}, 400);
} else {
const child = fork(__filename, ['child']);
2012-08-01 11:39:14 +00:00
child.on('disconnect', function() {
2012-08-01 11:39:14 +00:00
console.log('parent -> disconnect');
});
child.once('exit', function() {
2012-08-01 11:39:14 +00:00
console.log('parent -> exit');
});
}