|
|
1.1 ! root 1: #include <signal.h> ! 2: ! 3: static char status [NSIG]; ! 4: ! 5: /* status codes */ ! 6: #define NONE 0 ! 7: #define UNCAUGHT 1 ! 8: #define CAUGHT 2 ! 9: ! 10: static void ! 11: trap (sig) ! 12: { ! 13: if (sig >= 0 && sig < NSIG) ! 14: status[sig] = CAUGHT; ! 15: signal (sig, trap); ! 16: } ! 17: ! 18: int ! 19: sigtrap (sig) ! 20: register int sig; ! 21: { ! 22: register int cancel = 0, r = NONE; ! 23: ! 24: if (sig < 0) { ! 25: cancel++; ! 26: sig = -sig; ! 27: } ! 28: ! 29: if (sig > 0 && sig < NSIG) { ! 30: ! 31: r = status[sig]; ! 32: ! 33: if (cancel) { ! 34: status[sig] = NONE; ! 35: if (r != NONE && signal (sig, SIG_IGN) != SIG_IGN) ! 36: signal (sig, SIG_DFL); ! 37: } else { ! 38: status[sig] = UNCAUGHT; ! 39: if (r == NONE && signal (sig, SIG_IGN) != SIG_IGN) ! 40: signal (sig, trap); ! 41: } ! 42: } ! 43: ! 44: return r; ! 45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.