| 81 | |
| 82 | |
| 83 | void EventLoop::initialize() |
| 84 | { |
| 85 | // libev, when built with child process watcher support (the |
| 86 | // EV_CHILD_ENABLE feature flag), will install a SIGCHLD handler |
| 87 | // and wait on all processes. We need to save and restore the |
| 88 | // current signal handler in order to disable this behavior. |
| 89 | struct sigaction chldHandler; |
| 90 | |
| 91 | PCHECK(::sigaction(SIGCHLD, nullptr, &chldHandler) == 0); |
| 92 | |
| 93 | loop = ev_default_loop(EVFLAG_AUTO); |
| 94 | |
| 95 | PCHECK(::sigaction(SIGCHLD, &chldHandler, nullptr) == 0); |
| 96 | |
| 97 | ev_async_init(&async_watcher, handle_async); |
| 98 | ev_async_init(&shutdown_watcher, handle_shutdown); |
| 99 | |
| 100 | ev_async_start(loop, &async_watcher); |
| 101 | ev_async_start(loop, &shutdown_watcher); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | namespace internal { |