summaryrefslogtreecommitdiff
path: root/src/libstddjb/selfpipe_internal.c
blob: 45063bc28ade647938cb154c7c856c182bb9138a (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
32
33
/* 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 <unistd.h>
#include <errno.h>

#include <skalibs/allreadwrite.h>

int selfpipe[2] = { -1, -1 } ;

void selfpipe_tophalf (int s)
{
  int e = errno ;
  unsigned char c = (unsigned char)s ;
  write(selfpipe[1], (char *)&c, 1) ;
  errno = e ;
}

#endif