forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignal.c
More file actions
executable file
·35 lines (29 loc) · 871 Bytes
/
Copy pathsignal.c
File metadata and controls
executable file
·35 lines (29 loc) · 871 Bytes
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
/* SYSVR4 and ANSI compatible signal(2). */
#include <lib.h>
#define sigaction _sigaction
#define sigemptyset _sigemptyset
#include <signal.h>
PUBLIC sighandler_t signal(sig, disp)
int sig; /* signal number */
sighandler_t disp; /* signal handler, or SIG_DFL, or SIG_IGN */
{
struct sigaction sa, osa;
if (sig <= 0 || sig > _NSIG || sig == SIGKILL) {
errno = EINVAL;
return(SIG_ERR);
}
sigemptyset(&sa.sa_mask);
#ifdef WANT_UNRELIABLE_SIGNALS
/* Allow the signal being handled to interrupt the signal handler. */
sa.sa_flags = SA_NODEFER;
/* When signal is caught, reset signal handler to SIG_DFL for all but
* SIGILL and SIGTRAP.
*/
if (sig != SIGILL && sig != SIGTRAP) sa.sa_flags |= SA_RESETHAND;
#else
sa.sa_flags = 0;
#endif
sa.sa_handler = disp;
if (sigaction(sig, &sa, &osa) < 0) return(SIG_ERR);
return(osa.sa_handler);
}