-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
event-loop: poll a signalfd to know when to quit #79
Conversation
On one hand signalfd is Linux-specific, on the other hand we already use timerfd and epoll-shim already has support for both timerfd and signalfd. |
Portability could also be achieved by adding a signal handler that writes to a pipe and using the other end of the pipe as the "signalfd". It would require very little changes. I just don't see the point when so many other portions of the code base are non-portable. |
main.c
Outdated
@@ -37,6 +38,23 @@ static const char usage[] = | |||
"\n" | |||
"Colors can be specified with the format #RRGGBB or #RRGGBBAA.\n"; | |||
|
|||
static bool init_signalfd(struct mako_state *state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense to move this into event-loop.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that wouldn't be a bad idea. In what function, though? init_event_loop returns void so that seems like a bad fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init_event_loop
can be changed to return a bool
, and the signalfd can be stored in mako_event_loop
instead of mako_state
event-loop.c
Outdated
@@ -172,6 +177,9 @@ int run_event_loop(struct mako_event_loop *loop) { | |||
break; | |||
} | |||
|
|||
if (loop->fds[MAKO_EVENT_SIGNAL].revents & POLLIN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: please always use braces
Signed-off-by: Cameron Nemo <camerontnorman@gmail.com>
Thanks! |
Fixes #73
Signed-off-by: Cameron Nemo camerontnorman@gmail.com