From 1817d4b0626fda7821d8daf51db9559701603722 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 7 Oct 2009 01:35:21 +0200 Subject: [PATCH] ev_unref() the signal handlers. That means even if they are Attached(), libev will still exit if there is nothing else to do. --- src/signal_handler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/signal_handler.cc b/src/signal_handler.cc index ff00719219..cd022e6c6d 100644 --- a/src/signal_handler.cc +++ b/src/signal_handler.cc @@ -33,7 +33,10 @@ void SignalHandler::OnSignal(EV_P_ ev_signal *watcher, int revents) { } SignalHandler::~SignalHandler() { - ev_signal_stop(EV_DEFAULT_UC_ &watcher_); + if (watcher_.active) { + ev_unref(EV_DEFAULT_UC); + ev_signal_stop(EV_DEFAULT_UC_ &watcher_); + } } Handle SignalHandler::New(const Arguments& args) { @@ -51,6 +54,7 @@ Handle SignalHandler::New(const Arguments& args) { ev_signal_init(&handler->watcher_, SignalHandler::OnSignal, sig); handler->watcher_.data = handler; ev_signal_start(EV_DEFAULT_UC_ &handler->watcher_); + ev_unref(EV_DEFAULT_UC); handler->Attach(); @@ -61,6 +65,7 @@ Handle SignalHandler::Stop(const Arguments& args) { HandleScope scope; SignalHandler *handler = ObjectWrap::Unwrap(args.Holder()); + ev_ref(EV_DEFAULT_UC); ev_signal_stop(EV_DEFAULT_UC_ &handler->watcher_); handler->Detach(); return Undefined();