diff --git a/core/reactor.cc b/core/reactor.cc index e9b8abca55..2c11472e8d 100644 --- a/core/reactor.cc +++ b/core/reactor.cc @@ -44,7 +44,7 @@ reactor::reactor() _io_eventfd.wait().then([this] (size_t count) { process_io(count); }); - receive_signal(SIGINT).then([] { ::exit(255); }); + receive_signal(SIGINT).then([this] { _stopped = true; }); } future<> reactor::get_epoll_future(pollable_fd_state& pfd, @@ -266,6 +266,9 @@ void reactor::run() { current_tasks.clear(); } std::array eevt; + if (_stopped) { + break; + } int nr = ::epoll_wait(_epollfd.get(), eevt.data(), eevt.size(), -1); if (nr == -1 && errno == EINTR) { continue; // gdb can cause this diff --git a/core/reactor.hh b/core/reactor.hh index ea4a7dff38..677db57dd9 100644 --- a/core/reactor.hh +++ b/core/reactor.hh @@ -296,6 +296,7 @@ class reactor { signalfd_siginfo _siginfo; }; std::unordered_map _signal_handlers; + bool _stopped = false; public: file_desc _epollfd; readable_eventfd _io_eventfd;