event: Ensure the event loop has been cleaned up in event_teardown

- Add input_teardown/signal_teardown to take care of closing signal/stdin
  handles.
- Call those functions in event_teardown, and ensure there are no active handles
  by entering an infinite loop when there are unclosed handles(think of this as
  an assertion that can't go unoticed on travis).
- Move event_teardown call to the end of mch_exit. That is required because
  event_poll may still be called in that function.
This commit is contained in:
Thiago de Arruda
2014-11-02 16:37:31 -03:00
parent a1dd70b1d0
commit 75a5674cd2
4 changed files with 32 additions and 3 deletions

View File

@@ -55,6 +55,20 @@ void signal_init(void)
#endif
}
void signal_teardown(void)
{
signal_stop();
uv_close((uv_handle_t *)&sint, NULL);
uv_close((uv_handle_t *)&spipe, NULL);
uv_close((uv_handle_t *)&shup, NULL);
uv_close((uv_handle_t *)&squit, NULL);
uv_close((uv_handle_t *)&sterm, NULL);
uv_close((uv_handle_t *)&swinch, NULL);
#ifdef SIGPWR
uv_close((uv_handle_t *)&spwr, NULL);
#endif
}
void signal_stop(void)
{
uv_signal_stop(&sint);