From 9592bfd0dda7c575de07bce2c7a81b8432d845a4 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 28 Jul 2021 23:45:20 +0000 Subject: Huge incompatible changes. - Obsolete skalibs/environ.h and skalibs/getpeereid.h removed. - rc4 and md5 removed. - All *_t types renamed to avoid treading on POSIX namespace. - subgetopt() renamed to lgetopt(). - signal functions reworked; skasigaction removed; sig_stack removed - Various functions removed: skaoffsetof(), selfpipe_untrap() - New posixplz function: munmap_void. Signed-off-by: Laurent Bercot --- src/libstddjb/selfpipe_trap.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/libstddjb/selfpipe_trap.c') diff --git a/src/libstddjb/selfpipe_trap.c b/src/libstddjb/selfpipe_trap.c index 1dd4320..6ff8f09 100644 --- a/src/libstddjb/selfpipe_trap.c +++ b/src/libstddjb/selfpipe_trap.c @@ -4,9 +4,10 @@ #include #include + #include -#include "selfpipe-internal.h" #include +#include "selfpipe-internal.h" #ifdef SKALIBS_HASSIGNALFD @@ -16,18 +17,17 @@ int selfpipe_trap (int sig) { sigset_t ss = selfpipe_caught ; sigset_t old ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if ((sigaddset(&ss, sig) < 0) || (sigprocmask(SIG_BLOCK, &ss, &old) < 0)) - return -1 ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; + if ((sigaddset(&ss, sig) < 0) || (sigprocmask(SIG_BLOCK, &ss, &old) < 0)) return 0 ; if (signalfd(selfpipe_fd, &ss, SFD_NONBLOCK | SFD_CLOEXEC) < 0) { int e = errno ; sigprocmask(SIG_SETMASK, &old, 0) ; errno = e ; - return -1 ; + return 0 ; } selfpipe_caught = ss ; - return 0 ; + return 1 ; } #else @@ -36,16 +36,12 @@ int selfpipe_trap (int sig) int selfpipe_trap (int sig) { - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if (sig_catcha(sig, &selfpipe_ssa) < 0) return -1 ; - if (sigaddset(&selfpipe_caught, sig) < 0 || sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) < 0) - { - int e = errno ; - sig_restore(sig) ; - errno = e ; - return -1 ; - } - return 0 ; + sigset_t set ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; + if (!sig_catch(sig, &selfpipe_tophalf)) return 0 ; + sigaddset(&selfpipe_caught, sig) ; + sig_unblock(sig) ; + return 1 ; } #endif -- cgit v1.2.3