From 502f596c87b44c6711aefa011d9c672a802e336c Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 23 Feb 2023 12:07:46 -0800 Subject: [PATCH] Clean up dwmblocks-pulse-listener.c --- dwmblocks-pulse-listener.c | 14 +++++++++++--- dwmblocks.c | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dwmblocks-pulse-listener.c b/dwmblocks-pulse-listener.c index d7d6aa4..fe0ea2e 100644 --- a/dwmblocks-pulse-listener.c +++ b/dwmblocks-pulse-listener.c @@ -7,6 +7,14 @@ #define ERROR(...) fprintf(stderr, "error: " __VA_ARGS__) +#ifdef __OpenBSD__ +#define SIGMAX (SIGUSR2 - 1) +#define SIGMIN (SIGUSR1 - 1) +#else +#define SIGMAX SIGRTMAX +#define SIGMIN SIGRTMIN +#endif + typedef struct { size_t pid; unsigned int signum; @@ -79,15 +87,15 @@ int main(int argc, const char **argv) { return 1; } char *endptr = NULL; - unsigned int signum = SIGRTMIN + 1; + unsigned int signum = SIGMIN + 1; if (argc >= 3 && argv[1][0] == '-') { const char *signumstr = argv[1] + 1; unsigned long num = strtoul(signumstr, &endptr, 10); - if (num > (SIGRTMAX - SIGRTMIN) + 1) { + if (num > SIGMAX - SIGMIN) { ERROR("signal out of range: %lu\n", num); return 1; } - signum = SIGRTMIN + num; + signum = SIGMIN + num; ++argv; } endptr = NULL; diff --git a/dwmblocks.c b/dwmblocks.c index 169a31d..cd05dca 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -9,8 +9,8 @@ #include #endif #ifdef __OpenBSD__ -#define SIGPLUS SIGUSR1+1 -#define SIGMINUS SIGUSR1-1 +#define SIGPLUS (SIGUSR1 + 1) +#define SIGMINUS (SIGUSR1 - 1) #else #define SIGPLUS SIGRTMIN #define SIGMINUS SIGRTMIN