void event_teardown(void) { if (!deferred_events) { // Not initialized(possibly a --version invocation) return; } process_events_from(immediate_events); process_events_from(deferred_events); // reset the stop_flag to ensure `uv_run` below won't exit early. This hack // is required because the `process_events_from` above may call `event_push` // which will set the stop_flag to 1(uv_stop) uv_default_loop()->stop_flag = 0; input_stop_stdin(); channel_teardown(); job_teardown(); server_teardown(); signal_teardown(); terminal_teardown(); // this last `uv_run` will return after all handles are stopped, it will // also take care of finishing any uv_close calls made by other *_teardown // functions. uv_run(uv_default_loop(), UV_RUN_DEFAULT); // abort that if we left unclosed handles if (uv_loop_close(uv_default_loop())) { abort(); } }
void event_teardown() { channel_teardown(); job_teardown(); server_teardown(); }