Skip to content

Commit

Permalink
Fix missing SIGUSR2 posix signal handling (#5960)
Browse files Browse the repository at this point in the history
Since there is no separate error handling the `SIGUSR2` signal is
registered to get the write return code after exiting the program.

Fixes #5958

---------

Signed-off-by: Andre Werner <andre.werner@systec-electronic.com>
  • Loading branch information
systec-awe committed Mar 20, 2024
1 parent 910e585 commit 47cab33
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void handle_term_signal(struct ev_loop *loop, ev_signal *signal, int reve
*/
static void setup_term_handlers(void) {
static struct ev_signal signal_watchers[6];
size_t num_watchers = sizeof(signal_watchers) / sizeof(signal_watchers[0]);
const size_t num_watchers = sizeof(signal_watchers) / sizeof(signal_watchers[0]);

/* We have to rely on libev functionality here and should not use
* sigaction handlers because we need to invoke the exit handlers
Expand All @@ -252,7 +252,7 @@ static void setup_term_handlers(void) {
ev_signal_init(&signal_watchers[2], handle_term_signal, SIGALRM);
ev_signal_init(&signal_watchers[3], handle_term_signal, SIGTERM);
ev_signal_init(&signal_watchers[4], handle_term_signal, SIGUSR1);
ev_signal_init(&signal_watchers[5], handle_term_signal, SIGUSR1);
ev_signal_init(&signal_watchers[5], handle_term_signal, SIGUSR2);
for (size_t i = 0; i < num_watchers; i++) {
ev_signal_start(main_loop, &signal_watchers[i]);
/* The signal handlers should not block ev_run from returning
Expand Down

0 comments on commit 47cab33

Please sign in to comment.