Fix missing SIGUSR2 posix signal handling (#5960)

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>
This commit is contained in:
systec-awe 2024-03-20 13:58:56 +01:00 committed by GitHub
parent 910e58585f
commit 47cab33aa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
@ -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