Skip to content
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

Merged
merged 1 commit into from
Oct 22, 2018
Merged

event-loop: poll a signalfd to know when to quit #79

merged 1 commit into from
Oct 22, 2018

Conversation

CameronNemo
Copy link
Contributor

@CameronNemo CameronNemo commented Oct 21, 2018

Fixes #73

Signed-off-by: Cameron Nemo camerontnorman@gmail.com

@CameronNemo CameronNemo changed the title event-loop: stop using a signalfd event-loop: poll a signalfd to know when to quit Oct 21, 2018
@CameronNemo CameronNemo mentioned this pull request Oct 21, 2018
@emersion
Copy link
Owner

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.

@CameronNemo
Copy link
Contributor Author

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) {
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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)
Copy link
Owner

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>
@emersion emersion merged commit 15a3ea7 into emersion:master Oct 22, 2018
@emersion
Copy link
Owner

Thanks!

@CameronNemo CameronNemo deleted the signalfd branch December 13, 2018 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants