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

Resume all timers on SIGUSR2 #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ static void cmd_exec(char *param) {
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
signal(SIGUSR2, SIG_DFL);

char *const cmd[] = { "sh", "-c", param, NULL, };
execvp(cmd[0], cmd);
Expand Down Expand Up @@ -903,6 +904,16 @@ static int handle_signal(int sig, void *data) {
register_timeout(cmd, 0);
}
return 1;
case SIGUSR2:
swayidle_log(LOG_DEBUG, "Got SIGUSR2");
wl_list_for_each(cmd, &state.timeout_cmds, link) {
if (cmd->resume_pending) {
// Re-register to reset timeouts
cmd->registered_timeout = -1;
handle_resumed(cmd, NULL);
}
}
return 1;
}
abort(); // not reached
}
Expand Down Expand Up @@ -1048,6 +1059,7 @@ int main(int argc, char *argv[]) {
wl_event_loop_add_signal(state.event_loop, SIGINT, handle_signal, NULL);
wl_event_loop_add_signal(state.event_loop, SIGTERM, handle_signal, NULL);
wl_event_loop_add_signal(state.event_loop, SIGUSR1, handle_signal, NULL);
wl_event_loop_add_signal(state.event_loop, SIGUSR2, handle_signal, NULL);

state.display = wl_display_connect(NULL);
if (state.display == NULL) {
Expand Down