if (isolate->id_ > 1) {
process_l->Set(String::NewSymbol("_send"),
FunctionTemplate::New(Isolate::Send)->GetFunction());
+
+ process_l->Set(String::NewSymbol("_exit"),
+ FunctionTemplate::New(Isolate::Unref)->GetFunction());
}
// FIXME crashes with "CHECK(heap->isolate() == Isolate::Current()) failed"
msg = JSON.parse('' + msg);
process.emit('message', msg);
};
+
+ process.exit = process._exit;
}
startup.globalVariables = function() {
}
+Handle<Value> Isolate::Unref(const Arguments& args) {
+ HandleScope scope;
+
+ Isolate* isolate = Isolate::GetCurrent();
+ uv_unref(isolate->loop_);
+
+ return Undefined();
+}
+
+
void Isolate::OnMessage(IsolateMessage* msg, void* arg) {
HandleScope scope;
assert(v8_isolate_->GetData() == NULL);
v8_isolate_->SetData(this);
+ // Artificially ref the isolate loop so that the child
+ // isolate stays alive by default. process.exit will
+ // unref the loop (see Isolate::Unref).
+ uv_ref(loop_);
+
globals_init_ = false;
}
typedef void (*AtExitCallback)(void* arg);
static v8::Handle<v8::Value> Send(const v8::Arguments& args);
+ static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
static Isolate* GetCurrent() {
return reinterpret_cast<Isolate*>(v8::Isolate::GetCurrent()->GetData());
fs.stat(__dirname, function(err, stat) {
if (err) throw err;
console.error('thread 2', stat.mtime);
+ process.exit();
});
}, 500);