mirror of https://github.com/nodejs/node.git
child_process: spawn().ref() and spawn().unref()
parent
c45522df4c
commit
3116522e7c
|
@ -845,3 +845,13 @@ ChildProcess.prototype.kill = function(sig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ChildProcess.prototype.ref = function() {
|
||||||
|
if (this._handle) this._handle.ref();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ChildProcess.prototype.unref = function() {
|
||||||
|
if (this._handle) this._handle.unref();
|
||||||
|
};
|
||||||
|
|
|
@ -50,8 +50,18 @@ void HandleWrap::Initialize(Handle<Object> target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function is used only for process.stdout. It's put here instead of
|
Handle<Value> HandleWrap::Ref(const Arguments& args) {
|
||||||
// in TTYWrap because here we have access to the Close binding.
|
HandleScope scope;
|
||||||
|
|
||||||
|
UNWRAP(HandleWrap)
|
||||||
|
|
||||||
|
uv_ref(wrap->handle__);
|
||||||
|
wrap->unref_ = false;
|
||||||
|
|
||||||
|
return v8::Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Value> HandleWrap::Unref(const Arguments& args) {
|
Handle<Value> HandleWrap::Unref(const Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class HandleWrap {
|
||||||
public:
|
public:
|
||||||
static void Initialize(v8::Handle<v8::Object> target);
|
static void Initialize(v8::Handle<v8::Object> target);
|
||||||
static v8::Handle<v8::Value> Close(const v8::Arguments& args);
|
static v8::Handle<v8::Value> Close(const v8::Arguments& args);
|
||||||
|
static v8::Handle<v8::Value> Ref(const v8::Arguments& args);
|
||||||
static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
|
static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -67,6 +67,9 @@ class ProcessWrap : public HandleWrap {
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "spawn", Spawn);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "spawn", Spawn);
|
||||||
NODE_SET_PROTOTYPE_METHOD(constructor, "kill", Kill);
|
NODE_SET_PROTOTYPE_METHOD(constructor, "kill", Kill);
|
||||||
|
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref);
|
||||||
|
|
||||||
target->Set(String::NewSymbol("Process"), constructor->GetFunction());
|
target->Set(String::NewSymbol("Process"), constructor->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue