From 9a11da9d33fa4497eeca978cc99dc9b8381d8e37 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 5 Mar 2025 19:45:37 +0100 Subject: cleanup + cast + use pipe2 on linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/signals.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/signals.c') diff --git a/src/signals.c b/src/signals.c index 8cdb9e7..70addf8 100644 --- a/src/signals.c +++ b/src/signals.c @@ -51,31 +51,28 @@ int exiting = 0; int signals_install_handlers(void) { -#if !defined(__WIN32__) +#ifndef WINDOWS struct sigaction sigact; sigset_t sigset; - int r; - sigemptyset(&sigset); /* Install signal handler for INT and TERM signals */ + memset(&sigact, 0, sizeof(sigact)); + sigemptyset(&sigset); sigact.sa_handler = sigexit; sigact.sa_mask = sigset; sigact.sa_flags = 0; - r = sigaction(SIGINT, &sigact, NULL); - if (r < 0) { + if (sigaction(SIGINT, &sigact, NULL)) { perror("sigaction"); return -1; } - r = sigaction(SIGTERM, &sigact, NULL); - if (r < 0) { + if (sigaction(SIGTERM, &sigact, NULL)) { perror("sigaction"); return -1; } - r = sigaction(SIGQUIT, &sigact, NULL); - if (r < 0) { + if (sigaction(SIGQUIT, &sigact, NULL)) { perror("sigaction"); return -1; } @@ -85,8 +82,7 @@ signals_install_handlers(void) sigact.sa_mask = sigset; sigact.sa_flags = 0; - r = sigaction(SIGUSR1, &sigact, NULL); - if (r < 0) { + if (sigaction(SIGUSR1, &sigact, NULL)) { perror("sigaction"); return -1; } @@ -97,8 +93,7 @@ signals_install_handlers(void) sigact.sa_mask = sigset; sigact.sa_flags = 0; - r = sigaction(SIGCHLD, &sigact, NULL); - if (r < 0) { + if (sigaction(SIGCHLD, &sigact, NULL)) { perror("sigaction"); return -1; } -- cgit v1.2.3-70-g09d2