0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/fixtures/child-process-spawn-node.js
Ben Noordhuis 212466bea2 child_process: make .fork()'d child auto-exit
A child process created with .fork() needed to call `process.exit()` explicitly
because the communication channel with the parent kept the event loop alive.

Fix that by only ref'ing the channel when there are 'message' event listeners.

Fixes #3799.
2012-09-22 03:48:59 +02:00

11 lines
234 B
JavaScript

var assert = require('assert');
function onmessage(m) {
console.log('CHILD got message:', m);
assert.ok(m.hello);
process.removeListener('message', onmessage);
}
process.on('message', onmessage);
process.send({ foo: 'bar' });