Commit | Line | Data |
---|---|---|
b8f253e8 KM |
1 | /* |
2 | * Copyright (c) 1985 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
2ce81398 DS |
7 | #if defined(LIBC_SCCS) && !defined(lint) |
8 | static char sccsid[] = "@(#)signal.c 5.2 (Berkeley) %G%"; | |
9 | #endif LIBC_SCCS and not lint | |
3a2dc6bc | 10 | |
ddc47039 RC |
11 | /* |
12 | * Almost backwards compatible signal. | |
ddc47039 | 13 | */ |
3a2dc6bc KM |
14 | #include <signal.h> |
15 | ||
16 | int (* | |
17 | signal(s, a))() | |
18 | int s, (*a)(); | |
19 | { | |
20 | struct sigvec osv, sv; | |
21 | static int mask[NSIG]; | |
22 | static int flags[NSIG]; | |
ddc47039 | 23 | |
3a2dc6bc KM |
24 | sv.sv_handler = a; |
25 | sv.sv_mask = mask[s]; | |
26 | sv.sv_flags = flags[s]; | |
27 | if (sigvec(s, &sv, &osv) < 0) | |
28 | return (BADSIG); | |
29 | if (sv.sv_mask != osv.sv_mask || sv.sv_flags != osv.sv_flags) { | |
30 | mask[s] = sv.sv_mask = osv.sv_mask; | |
31 | flags[s] = sv.sv_flags = osv.sv_flags; | |
32 | if (sigvec(s, &sv, 0) < 0) | |
33 | return (BADSIG); | |
34 | } | |
35 | return (osv.sv_handler); | |
36 | } |