|
|
1.1 root 1: /* signals.c - signal handling */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/compat/RCS/signals.c,v 7.0 89/11/23 21:23:28 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/compat/RCS/signals.c,v 7.0 89/11/23 21:23:28 mrose Rel $
9: *
10: *
11: * $Log: signals.c,v $
12: * Revision 7.0 89/11/23 21:23:28 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: /* LINTLIBRARY */
29:
30: #include <signal.h>
31: #ifndef BADSIG
32: #define BADSIG ((SFP) -1)
33: #endif
34: #include "manifest.h"
35:
36: /* Berkeley UNIX: 4.2 */
37:
38: #ifdef BSDSIGS
39:
40: /* Simply including <signal.h> is sufficient for everything but AIX */
41:
42: #ifdef AIX /* #define'd to be _signal */
43: IFP signal (sig, func)
44: int sig;
45: IFP func;
46: {
47: struct sigvec sv1,
48: sv2;
49:
50: sv1.sv_handler = func;
51: sv1.sv_mask = sv1.sv_onstack = 0;
52: return (sigvec (sig, &sv1, &sv2) != NOTOK ? sv2.sv_handler : BADSIG);
53: }
54: #endif
55:
56: #else
57:
58: /* AT&T UNIX: 5 */
59:
60:
61: /* Probably a race condition or two in this code */
62:
63:
64: static int blocked = 0;
65: static int pending = 0;
66:
67: static SFP handler[NSIG];
68:
69:
70: static int sigser (sig)
71: int sig;
72: {
73: (void) signal (sig, sigser);
74:
75: pending |= sigmask (sig);
76: }
77:
78: /* */
79:
80: int sigblock (mask)
81: int mask;
82: {
83: register int sig,
84: smask;
85: long omask = blocked;
86:
87: if (mask == 0)
88: return blocked;
89:
90: for (sig = 1, smask = sigmask (sig); sig < NSIG; sig++, smask <<= 1)
91: if ((smask & mask) && !(smask & blocked)) {
92: pending &= ~smask;
93: handler[sig] = signal (sig, sigser);
94: blocked |= smask;
95: }
96:
97: return omask;
98: }
99:
100:
101: int sigsetmask (mask)
102: int mask;
103: {
104: register int sig,
105: smask;
106: long omask = blocked;
107:
108: for (sig = 1, smask = sigmask (sig); sig < NSIG; sig++, smask <<= 1)
109: if (smask & mask) {
110: if (smask & blocked)
111: continue;
112:
113: pending &= ~smask;
114: handler[sig] = signal (sig, sigser);
115: blocked |= smask;
116: }
117: else
118: if (smask & blocked) {
119: blocked &= ~smask;
120: (void) signal (sig, handler[sig] != BADSIG ? handler[sig]
121: : SIG_DFL);
122: if (smask & pending) {
123: pending &= ~smask;
124: (void) kill (getpid (), sig);
125: }
126: }
127:
128: return omask;
129: }
130:
131: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.