It is not safe. First there's the issue that ioloop.running is a bitmask,
but secondly there's a race condition between io_loop_stop() and the arrival
of the last timeout and/or IO event. It can end up running epoll_wait() with
only a stale IO and no timeouts, which hangs indefinitely.
void io_loop_run(struct ioloop *ioloop);
/* Stop the ioloop immediately. No further IO or timeout callbacks are called.
- This is safe to run in a signal handler. */
+ Warning: This is not safe to be called in non-delayed signal handlers. */
void io_loop_stop(struct ioloop *ioloop);
/* Stop ioloop after finishing all the pending IOs and timeouts. */
void io_loop_stop_delayed(struct ioloop *ioloop);