source: trunk/minix/lib/ansi/signal.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 871 bytes
Line 
1/* SYSVR4 and ANSI compatible signal(2). */
2
3#include <lib.h>
4#define sigaction _sigaction
5#define sigemptyset _sigemptyset
6#include <signal.h>
7
8PUBLIC sighandler_t signal(sig, disp)
9int sig; /* signal number */
10sighandler_t disp; /* signal handler, or SIG_DFL, or SIG_IGN */
11{
12 struct sigaction sa, osa;
13
14 if (sig <= 0 || sig > _NSIG || sig == SIGKILL) {
15 errno = EINVAL;
16 return(SIG_ERR);
17 }
18 sigemptyset(&sa.sa_mask);
19
20#ifdef WANT_UNRELIABLE_SIGNALS
21 /* Allow the signal being handled to interrupt the signal handler. */
22 sa.sa_flags = SA_NODEFER;
23
24 /* When signal is caught, reset signal handler to SIG_DFL for all but
25 * SIGILL and SIGTRAP.
26 */
27 if (sig != SIGILL && sig != SIGTRAP) sa.sa_flags |= SA_RESETHAND;
28#else
29 sa.sa_flags = 0;
30#endif
31
32 sa.sa_handler = disp;
33 if (sigaction(sig, &sa, &osa) < 0) return(SIG_ERR);
34 return(osa.sa_handler);
35}
Note: See TracBrowser for help on using the repository browser.