mirror of https://github.com/lukechilds/node.git
Ryan Dahl
14 years ago
9 changed files with 238 additions and 8 deletions
@ -0,0 +1,9 @@ |
|||
var assert = require('assert'); |
|||
|
|||
console.log("NODE_CHANNEL_FD", process.env.NODE_CHANNEL_FD); |
|||
assert.ok(process.env.NODE_CHANNEL_FD); |
|||
|
|||
var fd = parseInt(process.env.NODE_CHANNEL_FD); |
|||
assert.ok(fd >= 0); |
|||
|
|||
process.exit(0); |
@ -0,0 +1,10 @@ |
|||
var assert = require('assert'); |
|||
|
|||
process.on('message', function(m) { |
|||
console.log('CHILD got message:', m); |
|||
assert.ok(m.hello); |
|||
// Note that we have to force exit.
|
|||
process.exit(); |
|||
}); |
|||
|
|||
process.send({ foo: 'bar' }); |
@ -0,0 +1,25 @@ |
|||
var assert = require('assert'); |
|||
var spawn = require('child_process').spawn; |
|||
var common = require('../common'); |
|||
|
|||
var sub = common.fixturesDir + '/child-process-channel.js'; |
|||
|
|||
var child = spawn(process.execPath, [ sub ], { |
|||
customFds: [0, 1, 2], |
|||
wantChannel: true |
|||
}); |
|||
|
|||
console.log("fds", child.fds); |
|||
|
|||
assert.ok(child.fds.length == 4); |
|||
assert.ok(child.fds[3] >= 0); |
|||
|
|||
var childExitCode = -1; |
|||
|
|||
child.on('exit', function(code) { |
|||
childExitCode = code; |
|||
}); |
|||
|
|||
process.on('exit', function() { |
|||
assert.ok(childExitCode == 0); |
|||
}); |
@ -0,0 +1,24 @@ |
|||
var assert = require('assert'); |
|||
var common = require('../common'); |
|||
var spawnNode = require('child_process').spawnNode; |
|||
|
|||
var n = spawnNode(common.fixturesDir + '/child-process-spawn-node.js'); |
|||
|
|||
var messageCount = 0; |
|||
|
|||
n.on('message', function(m) { |
|||
console.log('PARENT got message:', m); |
|||
assert.ok(m.foo); |
|||
messageCount++; |
|||
}); |
|||
|
|||
n.send({ hello: 'world' }); |
|||
|
|||
var childExitCode = -1; |
|||
n.on('exit', function(c) { |
|||
childExitCode = c; |
|||
}); |
|||
|
|||
process.on('exit', function() { |
|||
assert.ok(childExitCode == 0); |
|||
}); |
Loading…
Reference in new issue