initial pass at lib/child_process_uv.js
This commit is contained in:
parent
d3d8f1b972
commit
7772f21b60
4
Makefile
4
Makefile
@ -233,6 +233,10 @@ UVTEST += simple/test-tls-request-timeout
|
|||||||
#UVTEST += simple/test-tls-server-verify # broken
|
#UVTEST += simple/test-tls-server-verify # broken
|
||||||
UVTEST += simple/test-tls-set-encoding
|
UVTEST += simple/test-tls-set-encoding
|
||||||
|
|
||||||
|
# child_process
|
||||||
|
UVTEST += simple/test-child-process-exit-code.js
|
||||||
|
UVTEST += simple/test-child-process-buffering.js
|
||||||
|
|
||||||
|
|
||||||
test-uv: all
|
test-uv: all
|
||||||
NODE_USE_UV=1 python tools/test.py $(UVTEST)
|
NODE_USE_UV=1 python tools/test.py $(UVTEST)
|
||||||
|
@ -3,8 +3,19 @@ var stream = require('stream');
|
|||||||
var timers = require('timers');
|
var timers = require('timers');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var TCP = process.binding('tcp_wrap').TCP;
|
|
||||||
var Pipe = process.binding('pipe_wrap').Pipe;
|
// constructor for lazy loading
|
||||||
|
function createPipe() {
|
||||||
|
var Pipe = process.binding('pipe_wrap').Pipe;
|
||||||
|
return new Pipe();
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor for lazy loading
|
||||||
|
function createTCP() {
|
||||||
|
var TCP = process.binding('tcp_wrap').TCP;
|
||||||
|
return new TCP();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Bit flags for socket._flags */
|
/* Bit flags for socket._flags */
|
||||||
var FLAG_GOT_EOF = 1 << 0;
|
var FLAG_GOT_EOF = 1 << 0;
|
||||||
@ -35,7 +46,7 @@ exports.connect = exports.createConnection = function(port /* [host], [cb] */) {
|
|||||||
var s;
|
var s;
|
||||||
|
|
||||||
if (isPipeName(port)) {
|
if (isPipeName(port)) {
|
||||||
s = new Socket({handle:new Pipe});
|
s = new Socket({ handle: createPipe() });
|
||||||
} else {
|
} else {
|
||||||
s = new Socket();
|
s = new Socket();
|
||||||
}
|
}
|
||||||
@ -411,7 +422,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) {
|
|||||||
var pipe = isPipeName(port);
|
var pipe = isPipeName(port);
|
||||||
|
|
||||||
if (this.destroyed || !this._handle) {
|
if (this.destroyed || !this._handle) {
|
||||||
this._handle = pipe ? new Pipe() : new TCP();
|
this._handle = pipe ? createPipe() : createTCP();
|
||||||
initSocketHandle(this);
|
initSocketHandle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +555,8 @@ function listen(self, address, port, addressType) {
|
|||||||
|
|
||||||
if (!self._handle) {
|
if (!self._handle) {
|
||||||
// assign handle in listen, and clean up if bind or listen fails
|
// assign handle in listen, and clean up if bind or listen fails
|
||||||
self._handle = (port == -1 && addressType == -1) ? new Pipe : new TCP;
|
self._handle =
|
||||||
|
(port == -1 && addressType == -1) ? createPipe() : createTCP();
|
||||||
}
|
}
|
||||||
|
|
||||||
self._handle.socket = self;
|
self._handle.socket = self;
|
||||||
|
@ -411,6 +411,10 @@
|
|||||||
case 'net':
|
case 'net':
|
||||||
return process.features.uv ? 'net_uv' : 'net_legacy';
|
return process.features.uv ? 'net_uv' : 'net_legacy';
|
||||||
|
|
||||||
|
case 'child_process':
|
||||||
|
return process.features.uv ? 'child_process_uv' :
|
||||||
|
'child_process_legacy';
|
||||||
|
|
||||||
case 'timers':
|
case 'timers':
|
||||||
return process.features.uv ? 'timers_uv' : 'timers_legacy';
|
return process.features.uv ? 'timers_uv' : 'timers_legacy';
|
||||||
|
|
||||||
|
@ -149,6 +149,8 @@ class ProcessWrap : public HandleWrap {
|
|||||||
wrap->SetHandle((uv_handle_t*)&wrap->process_);
|
wrap->SetHandle((uv_handle_t*)&wrap->process_);
|
||||||
assert(wrap->process_.data == wrap);
|
assert(wrap->process_.data == wrap);
|
||||||
|
|
||||||
|
wrap->object_->Set(String::New("pid"), Integer::New(wrap->process_.pid));
|
||||||
|
|
||||||
if (options.args) {
|
if (options.args) {
|
||||||
for (int i = 0; options.args[i]; i++) free(options.args[i]);
|
for (int i = 0; options.args[i]; i++) free(options.args[i]);
|
||||||
delete [] options.args;
|
delete [] options.args;
|
||||||
|
@ -30,11 +30,14 @@ var processExited = false;
|
|||||||
var gotPipeEOF = false;
|
var gotPipeEOF = false;
|
||||||
var gotPipeData = false;
|
var gotPipeData = false;
|
||||||
|
|
||||||
p.onexit = function() {
|
p.onexit = function(exitCode, signal) {
|
||||||
console.log("exit");
|
console.log("exit");
|
||||||
p.close();
|
p.close();
|
||||||
pipe.readStart();
|
pipe.readStart();
|
||||||
|
|
||||||
|
assert.equal(0, exitCode);
|
||||||
|
assert.equal(0, signal);
|
||||||
|
|
||||||
processExited = true;
|
processExited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user