From 6747c5f3f8d677bd553699710c1b99f5ae98f309 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Fri, 18 Sep 2020 15:06:29 +0200 Subject: poller: Raise signals through self-pipe Signal handling relied on poll(2) being interrupted by signals, followed by a check for signal handlers flagging a signal as received. This only allowed signals that were received during poll(2) to be handled correctly. Implement the usual self-pipe implementation, where signal handlers write an arbitrary byte to a polled file descriptor to ensure proper level-triggered signal handling. --- include/poller.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/poller.h') diff --git a/include/poller.h b/include/poller.h index f30bbda..63733e2 100644 --- a/include/poller.h +++ b/include/poller.h @@ -71,10 +71,11 @@ struct poller { struct linked_list signals; struct linked_list fds; + int signal_fds[2]; struct pollfd *pollfds; size_t pollfds_len; size_t fd_event_sources; - bool pollfds_dirty; + bool dirty; }; /** @@ -96,7 +97,7 @@ struct poll_impl { * Initializes the poller. The poller must be torn down with poller_finish when * it is no longer needed. */ -void poller_init(struct poller *poller); +int poller_init(struct poller *poller); /** * De-initializes the poller. This destroys all remaining event sources and -- cgit v1.2.3