diff --git a/main.c b/main.c index 9bf29e5..15de66d 100644 --- a/main.c +++ b/main.c @@ -107,16 +107,13 @@ int main(int argc, char *argv[]) /* * Register signal handler for SIGTERM and SIGINT. - * - * The behaviour of signal() is not entirely consistent across - * different implementations, so this should ideally be rewritten - * to use signaction() instead at some point. */ - if (signal(SIGTERM, handle_exit_signal) == SIG_ERR) { + const struct sigaction act = { .sa_handler = handle_exit_signal }; + if (sigaction(SIGTERM, &act, NULL) == -1) { fprintf(stderr, "Failed to register SIGTERM signal handler\n"); return EXIT_FAILURE; } - if (signal(SIGINT, handle_exit_signal) == SIG_ERR) { + if (sigaction(SIGINT, &act, NULL) == -1) { fprintf(stderr, "Failed to register SIGINT signal handler\n"); return EXIT_FAILURE; }