summaryrefslogtreecommitdiff
path: root/src/libstddjb/selfpipe_internal.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
commit3534b428629be185e096be99e3bd5fdfe32d5544 (patch)
tree210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/libstddjb/selfpipe_internal.c
downloadskalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libstddjb/selfpipe_internal.c')
-rw-r--r--src/libstddjb/selfpipe_internal.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libstddjb/selfpipe_internal.c b/src/libstddjb/selfpipe_internal.c
new file mode 100644
index 0000000..e5d5d95
--- /dev/null
+++ b/src/libstddjb/selfpipe_internal.c
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+/* MT-unsafe */
+
+#include <signal.h>
+#include <skalibs/sysdeps.h>
+#include "selfpipe-internal.h"
+
+sigset_t selfpipe_caught ;
+
+#ifdef SKALIBS_HASSIGNALFD
+
+int selfpipe_fd = -1 ;
+
+#else
+
+#include <errno.h>
+#include <skalibs/allreadwrite.h>
+#include <skalibs/djbunix.h>
+
+int selfpipe[2] = { -1, -1 } ;
+
+static void selfpipe_trigger (int s)
+{
+ char c = (char)s ;
+ fd_write(selfpipe[1], &c, 1) ;
+}
+
+struct skasigaction const selfpipe_ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ;
+
+#endif