summary refs log tree commit diff
path: root/src/libstddjb/selfpipe_internal.c
blob: f65e07a7b2f57937382c70ef1a93e7de9d610f06 (plain) (blame)
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)
{
  unsigned char c = (unsigned char)s ;
  fd_write(selfpipe[1], (char *)&c, 1) ;
}

struct skasigaction const selfpipe_ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ;

#endif