summaryrefslogtreecommitdiff
path: root/src/libstddjb/selfpipe_trap.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-07-28 23:45:20 +0000
committerLaurent Bercot <ska@appnovation.com>2021-07-28 23:45:20 +0000
commit9592bfd0dda7c575de07bce2c7a81b8432d845a4 (patch)
tree57c66c3e0dfeb63cfd3ebfef18e30a2145ae3f88 /src/libstddjb/selfpipe_trap.c
parentc15bccec3fd551583ff838673ba284ee6c7e788a (diff)
downloadskalibs-9592bfd0dda7c575de07bce2c7a81b8432d845a4.tar.xz
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 <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/selfpipe_trap.c')
-rw-r--r--src/libstddjb/selfpipe_trap.c28
1 files changed, 12 insertions, 16 deletions
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 <errno.h>
#include <signal.h>
+
#include <skalibs/sysdeps.h>
-#include "selfpipe-internal.h"
#include <skalibs/selfpipe.h>
+#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