-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We used sigsetjmp() and siglogjmp() for signal handling, which is very hard to use correctly and too magical. Replace it with the kqueue(), which can notify events on sockets and signals. The get signals with kqueue, we need to block them. This has the nice property that no function in any thread will fail with EINTR when we receive a signal, which simplifies the code. We setup signal handling before we open the pidfile, so receiving a signal after the pidfile was created will always remove the pidfile. Before this change we has a small window when receiving a signal would terminate the process without removing the pidfile. To wait for connection or signal, we wait for kqueue events. If we receiving a signal we break the loop and exit normally, since termination by signal is normal. This can help programs running socket_vment that may be confused by exit code 1. Notes: - Keeping listen_fd in blocking mode to simplify the code. accept() should not block when we receive a EVFILT_READ event. We can change to non-blocking mode later if this assumption is wrong. Signed-off-by: Nir Soffer <[email protected]>
- Loading branch information
Showing
1 changed file
with
88 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters