summaryrefslogtreecommitdiff
path: root/libc/signal/signal.c
blob: 2397c55e799ada4c223e6cc088f0a11a61fefc53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <string.h>
#include <signal.h>

/* Global variable */
sigset_t _sigintr;              /* Set by siginterrupt.  */

__sighandler_t
__signal (int sig, __sighandler_t handler, int flags)
{
  int ret;
  struct sigaction action, oaction;
  memset(&action, 0, sizeof(struct sigaction));
  action.sa_handler = handler;
  action.sa_flags = flags;
  ret = sigaction (sig, &action, &oaction); 
  return (ret == -1) ? SIG_ERR : oaction.sa_handler;
}

__sighandler_t
signal (int sig, __sighandler_t handler)
{
  return __signal(sig, handler, (SA_ONESHOT | SA_NOMASK | SA_INTERRUPT) & ~SA_RESTART);
}