summaryrefslogtreecommitdiff
path: root/src/libstddjb/selfpipe_finish.c
blob: 5d9b3fd484a02de72443fe48a83eeec59485147f (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
34
35
/* ISC license. */

/* MT-unsafe */

#include <skalibs/sysdeps.h>
#include <signal.h>
#include <skalibs/djbunix.h>
#include "selfpipe-internal.h"
#include <skalibs/selfpipe.h>

#ifdef SKALIBS_HASSIGNALFD

void selfpipe_finish (void)
{
  sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) ;
  sigemptyset(&selfpipe_caught) ;
  fd_close(selfpipe_fd) ;
  selfpipe_fd = -1 ;
}

#else

#include <skalibs/sig.h>
#include <skalibs/nsig.h>

void selfpipe_finish (void)
{
  sig_restoreto(&selfpipe_caught, NSIG) ;
  sigemptyset(&selfpipe_caught) ;
  fd_close(selfpipe[1]) ;
  fd_close(selfpipe[0]) ;
  selfpipe[0] = selfpipe[1] = -1 ;
}

#endif