From 37b1549f792005caaa2d87716b8f71cb1efc390f Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sun, 24 Jul 2022 17:58:55 +0500 Subject: [PATCH] Fix: __sighandler_t is not portable --- src/server.c | 6 ------ src/utils.c | 6 ++++++ src/utils.h | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/server.c b/src/server.c index 10602ef..0e14f9b 100644 --- a/src/server.c +++ b/src/server.c @@ -34,12 +34,6 @@ static void sig_handler_exit(int s) do_exit = 1; } -static int register_signal(int sig, __sighandler_t handler) -{ - ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR); - return OK; -} - static int open_fifo(int *fd, char *f) { ERRCHK_RET_ERN((*fd = open(f, O_RDONLY | O_NONBLOCK)) == -1); diff --git a/src/utils.c b/src/utils.c index 894bd6c..1b382ad 100644 --- a/src/utils.c +++ b/src/utils.c @@ -159,3 +159,9 @@ const char *get_ext(const char *path) return dot; } + +int register_signal(int sig, SigHandler handler) +{ + ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR); + return OK; +} diff --git a/src/utils.h b/src/utils.h index 3e8194f..c9c41b4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -23,6 +23,8 @@ typedef int (*SpawnProg)(const void *); +typedef void (*SigHandler)(int); + extern char *program; int spawn_redirect(const void *arg); @@ -39,4 +41,6 @@ int get_config_dir(char *buf, size_t len, char *name); int mkpath(char* file_path, int mode); const char *get_ext(const char *path); +int register_signal(int sig, SigHandler handler); + #endif