summaryrefslogtreecommitdiff
path: root/src/libstddjb/selfpipe_internal.c
blob: e5d5d950b40a3dc42ff29ec74ba1ad8c1607d146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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