map in kernel in 4MB, global-bit-set 'pages' if hardware
[minix.git] / lib / ansi / signal.c
bloba8cdca1fe64e15ac2eeb6039c11530084220d759
1 /* SYSVR4 and ANSI compatible signal(2). */
3 #include <lib.h>
4 #define sigaction _sigaction
5 #define sigemptyset _sigemptyset
6 #include <signal.h>
8 PUBLIC sighandler_t signal(sig, disp)
9 int sig; /* signal number */
10 sighandler_t disp; /* signal handler, or SIG_DFL, or SIG_IGN */
12 struct sigaction sa, osa;
14 if (sig <= 0 || sig > _NSIG || sig == SIGKILL) {
15 errno = EINVAL;
16 return(SIG_ERR);
18 sigemptyset(&sa.sa_mask);
20 #ifdef WANT_UNRELIABLE_SIGNALS
21 /* Allow the signal being handled to interrupt the signal handler. */
22 sa.sa_flags = SA_NODEFER;
24 /* When signal is caught, reset signal handler to SIG_DFL for all but
25 * SIGILL and SIGTRAP.
27 if (sig != SIGILL && sig != SIGTRAP) sa.sa_flags |= SA_RESETHAND;
28 #else
29 sa.sa_flags = 0;
30 #endif
32 sa.sa_handler = disp;
33 if (sigaction(sig, &sa, &osa) < 0) return(SIG_ERR);
34 return(osa.sa_handler);