|
|
1.1 root 1: static char *sccsid = "@(#)sh.sig.c 4.1 (Berkeley) 83/06/11";
2:
3: /*
4: * C shell - old jobs library sigrelse meant unblock mask
5: * AND reinstall handler, so we simulate it here.
6: */
7: #include <signal.h>
8:
9: #define mask(s) (1 << ((s)-1))
10:
11: static int (*actions[NSIG])();
12: static int achanged[NSIG];
13:
14: /*
15: * Perform action and save handler state.
16: */
17: sigset(s, a)
18: int s, (*a)();
19: {
20:
21: actions[s] = a;
22: achanged[s] = 0;
23: return ((int)signal(s, a));
24: }
25:
26: /*
27: * Release any masking of signal and
28: * reinstall handler in case someone's
29: * done a sigignore.
30: */
31: sigrelse(s)
32: int s;
33: {
34:
35: if (achanged[s]) {
36: signal(s, actions[s]);
37: achanged[s] = 0;
38: }
39: sigsetmask(sigblock(0) &~ mask(s));
40: }
41:
42: /*
43: * Ignore signal but maintain state so sigrelse
44: * will restore handler. We avoid the overhead
45: * of doing a signal for each sigrelse call by
46: * marking the signal's action as changed.
47: */
48: sigignore(s)
49: int s;
50: {
51:
52: if (actions[s] != SIG_IGN)
53: achanged[s] = 1;
54: signal(s, SIG_IGN);
55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.