joyent/node — Issue #2254: child_process.fork bug
Author: cadorn
Created: 2011-12-03 01:34:45+00:00
State: open

Node v0.6.4

I have a wired child_process.fork bug.

Given two files:

node-fork.js

var FORK = require('child_process').fork,
PATH = require("path");

FORK(PATH.dirname(module.id) + "/node-exec.js", [], {
env: process.env,
cwd: process.cwd()
});
process.exit(0);

node-exec.js

var EXEC = require('child_process').exec;

EXEC("npm --verbose install -f nodemailer@0.2.3", {
cwd: "/pinf/tmp/1/node_modules"
}, function (error, stdout, stderr) {

console.log("error", error);
console.log("stdout", stdout);
console.log("stderr", stderr);

EXEC("npm --verbose install -f nodemailer@0.2.3", {
cwd: "/pinf/tmp/node_modules"
}, function (error, stdout, stderr) {

console.log("error", error);
console.log("stdout", stdout);
console.log("stderr", stderr);
});
});

and running: 'node node-fork.js'

I get:

stdout nodemailer@0.2.3 ./nodemailer

npm verb exit [ 0, true ]
npm info ok

error { [Error: Command failed: Assertion failed: (stream->fd >= 0), function uv__write, file src/unix/stream.c, line 346.
] killed: false, code: null, signal: 'SIGABRT' }
stdout
stderr Assertion failed: (stream->fd >= 0), function uv__write, file src/unix/stream.c, line 346.

Notice the output of the second EXEC. If calling 'node node-exec.js' without forking everything works as expected.