diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index ca08342ec63bb1..ba5ceb95025fd0 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -101,7 +101,17 @@ class SignalWrap : public HandleWrap { } } #endif - int err = uv_signal_start(&wrap->handle_, OnSignal, signum); + int err = uv_signal_start( + &wrap->handle_, + [](uv_signal_t* handle, int signum) { + SignalWrap* wrap = ContainerOf(&SignalWrap::handle_, handle); + Environment* env = wrap->env(); + HandleScope handle_scope(env->isolate()); + Context::Scope context_scope(env->context()); + Local arg = Integer::New(env->isolate(), signum); + wrap->MakeCallback(env->onsignal_string(), 1, &arg); + }, + signum); args.GetReturnValue().Set(err); } @@ -112,16 +122,6 @@ class SignalWrap : public HandleWrap { args.GetReturnValue().Set(err); } - static void OnSignal(uv_signal_t* handle, int signum) { - SignalWrap* wrap = ContainerOf(&SignalWrap::handle_, handle); - Environment* env = wrap->env(); - HandleScope handle_scope(env->isolate()); - Context::Scope context_scope(env->context()); - - Local arg = Integer::New(env->isolate(), signum); - wrap->MakeCallback(env->onsignal_string(), 1, &arg); - } - uv_signal_t handle_; };