diff options
Diffstat (limited to 'src/libstddjb/selfpipe_internal.c')
-rw-r--r-- | src/libstddjb/selfpipe_internal.c | 31 |
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 |