core: exit program by breaking the loop rather than exit()

This gives more destructors the option to run, making an easier job for
leak detectors.
This commit is contained in:
Avi Kivity
2014-09-08 21:21:00 +03:00
parent d06508927e
commit c14daba9e6
2 changed files with 5 additions and 1 deletions

View File

@@ -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<epoll_event, 128> 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

View File

@@ -296,6 +296,7 @@ class reactor {
signalfd_siginfo _siginfo;
};
std::unordered_map<int, signal_handler> _signal_handlers;
bool _stopped = false;
public:
file_desc _epollfd;
readable_eventfd _io_eventfd;