|
@ -25,7 +25,6 @@ var Process = process.binding('process_wrap').Process; |
|
|
var inherits = require('util').inherits; |
|
|
var inherits = require('util').inherits; |
|
|
var constants; // if (!constants) constants = process.binding('constants');
|
|
|
var constants; // if (!constants) constants = process.binding('constants');
|
|
|
|
|
|
|
|
|
var LF = '\n'.charCodeAt(0); |
|
|
|
|
|
var Pipe; |
|
|
var Pipe; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,8 +75,8 @@ function setupChannel(target, channel) { |
|
|
|
|
|
|
|
|
if (isWindows) { |
|
|
if (isWindows) { |
|
|
var setSimultaneousAccepts = function(handle) { |
|
|
var setSimultaneousAccepts = function(handle) { |
|
|
var simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS |
|
|
var simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS && |
|
|
&& process.env.NODE_MANY_ACCEPTS != '0') ? true : false; |
|
|
process.env.NODE_MANY_ACCEPTS != '0') ? true : false; |
|
|
|
|
|
|
|
|
if (handle._simultaneousAccepts != simultaneousAccepts) { |
|
|
if (handle._simultaneousAccepts != simultaneousAccepts) { |
|
|
handle.setSimultaneousAccepts(simultaneousAccepts); |
|
|
handle.setSimultaneousAccepts(simultaneousAccepts); |
|
@ -101,7 +100,7 @@ function setupChannel(target, channel) { |
|
|
var message = JSON.parse(json); |
|
|
var message = JSON.parse(json); |
|
|
|
|
|
|
|
|
target.emit('message', message, recvHandle); |
|
|
target.emit('message', message, recvHandle); |
|
|
start = i+1; |
|
|
start = i + 1; |
|
|
} |
|
|
} |
|
|
jsonBuffer = jsonBuffer.slice(start); |
|
|
jsonBuffer = jsonBuffer.slice(start); |
|
|
|
|
|
|
|
@ -112,7 +111,7 @@ function setupChannel(target, channel) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
target.send = function(message, sendHandle) { |
|
|
target.send = function(message, sendHandle) { |
|
|
if (!target._channel) throw new Error("channel closed"); |
|
|
if (!target._channel) throw new Error('channel closed'); |
|
|
|
|
|
|
|
|
// For overflow protection don't write if channel queue is too deep.
|
|
|
// For overflow protection don't write if channel queue is too deep.
|
|
|
if (channel.writeQueueSize > 1024 * 1024) { |
|
|
if (channel.writeQueueSize > 1024 * 1024) { |
|
@ -129,7 +128,7 @@ function setupChannel(target, channel) { |
|
|
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle); |
|
|
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle); |
|
|
|
|
|
|
|
|
if (!writeReq) { |
|
|
if (!writeReq) { |
|
|
throw new Error(errno + " cannot write to IPC channel."); |
|
|
throw new Error(errno + 'cannot write to IPC channel.'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
writeReq.oncomplete = nop; |
|
|
writeReq.oncomplete = nop; |
|
@ -151,16 +150,16 @@ exports.fork = function(modulePath, args, options) { |
|
|
args.unshift(modulePath); |
|
|
args.unshift(modulePath); |
|
|
|
|
|
|
|
|
if (options.stdinStream) { |
|
|
if (options.stdinStream) { |
|
|
throw new Error("stdinStream not allowed for fork()"); |
|
|
throw new Error('stdinStream not allowed for fork()'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (options.customFds) { |
|
|
if (options.customFds) { |
|
|
throw new Error("customFds not allowed for fork()"); |
|
|
throw new Error('customFds not allowed for fork()'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Leave stdin open for the IPC channel. stdout and stderr should be the
|
|
|
// Leave stdin open for the IPC channel. stdout and stderr should be the
|
|
|
// same as the parent's.
|
|
|
// same as the parent's.
|
|
|
options.customFds = [ -1, 1, 2 ]; |
|
|
options.customFds = [-1, 1, 2]; |
|
|
|
|
|
|
|
|
// Just need to set this - child process won't actually use the fd.
|
|
|
// Just need to set this - child process won't actually use the fd.
|
|
|
// For backwards compat - this can be changed to 'NODE_CHANNEL' before v0.6.
|
|
|
// For backwards compat - this can be changed to 'NODE_CHANNEL' before v0.6.
|
|
@ -331,7 +330,6 @@ var spawn = exports.spawn = function(file, args, options) { |
|
|
|
|
|
|
|
|
var env = (options ? options.env : null) || process.env; |
|
|
var env = (options ? options.env : null) || process.env; |
|
|
var envPairs = []; |
|
|
var envPairs = []; |
|
|
var keys = Object.keys(env); |
|
|
|
|
|
for (var key in env) { |
|
|
for (var key in env) { |
|
|
envPairs.push(key + '=' + env[key]); |
|
|
envPairs.push(key + '=' + env[key]); |
|
|
} |
|
|
} |
|
|