mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
child process now use net.Socket
This commit is contained in:
parent
953fa3a5f5
commit
04c06b9149
24 changed files with 519 additions and 521 deletions
35
lib/sys.js
35
lib/sys.js
|
@ -16,7 +16,7 @@ exports.debug = function (x) {
|
|||
process.binding('stdio').writeError("DEBUG: " + x + "\n");
|
||||
};
|
||||
|
||||
exports.error = function (x) {
|
||||
var error = exports.error = function (x) {
|
||||
for (var i = 0, len = arguments.length; i < len; ++i) {
|
||||
process.binding('stdio').writeError(arguments[i] + '\n');
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ exports.inspect = function (obj, showHidden, depth) {
|
|||
|
||||
exports.p = function () {
|
||||
for (var i = 0, len = arguments.length; i < len; ++i) {
|
||||
exports.error(exports.inspect(arguments[i]));
|
||||
error(exports.inspect(arguments[i]));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,29 +207,14 @@ exports.log = function (msg) {
|
|||
exports.puts(timestamp() + ' - ' + msg.toString());
|
||||
}
|
||||
|
||||
exports.exec = function (command, callback) {
|
||||
var child = process.createChildProcess("/bin/sh", ["-c", command]);
|
||||
var stdout = "";
|
||||
var stderr = "";
|
||||
|
||||
child.addListener("output", function (chunk) {
|
||||
if (chunk) stdout += chunk;
|
||||
});
|
||||
|
||||
child.addListener("error", function (chunk) {
|
||||
if (chunk) stderr += chunk;
|
||||
});
|
||||
|
||||
child.addListener("exit", function (code) {
|
||||
if (code == 0) {
|
||||
if (callback) callback(null, stdout, stderr);
|
||||
} else {
|
||||
var e = new Error("Command failed: " + stderr);
|
||||
e.code = code;
|
||||
if (callback) callback(e, stdout, stderr);
|
||||
}
|
||||
});
|
||||
};
|
||||
var execWarning;
|
||||
exports.exec = function () {
|
||||
if (!execWarning) {
|
||||
execWarning = 'sys.exec has moved to the "child_process" module. Please update your source code.'
|
||||
error(execWarning);
|
||||
}
|
||||
return require('child_process').exec.apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue