summaryrefslogtreecommitdiff
path: root/src/libstddjb/sig_catch.c
blob: 5195d4bc5ec647a4e8662dd380e287c4c683b443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ISC license. */

/* MT-unsafe */

#include <signal.h>

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

int sig_catch (int sig, sig_func_ref f)
{
  struct sigaction action = { .sa_handler = f, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ;
  sigfillset(&action.sa_mask) ;
  return sigaction(sig, &action, 0) >= 0 ;
}