Arrange for SIGINT etc. to be caught by the handler. */
| 1097 | static void |
| 1098 | catch_signals(void) |
| 1099 | { |
| 1100 | static int const signals[] = { |
| 1101 | #ifdef SIGHUP |
| 1102 | SIGHUP, |
| 1103 | #endif |
| 1104 | SIGINT, |
| 1105 | #ifdef SIGPIPE |
| 1106 | SIGPIPE, |
| 1107 | #endif |
| 1108 | SIGTERM |
| 1109 | }; |
| 1110 | int i; |
| 1111 | for (i = 0; i < sizeof signals / sizeof signals[0]; i++) { |
| 1112 | #ifdef SA_SIGINFO |
| 1113 | struct sigaction act0, act; |
| 1114 | act.sa_handler = signal_handler; |
| 1115 | sigemptyset(&act.sa_mask); |
| 1116 | act.sa_flags = 0; |
| 1117 | if (sigaction(signals[i], &act, &act0) == 0 |
| 1118 | && ! (act0.sa_flags & SA_SIGINFO) && act0.sa_handler == SIG_IGN) { |
| 1119 | sigaction(signals[i], &act0, NULL); |
| 1120 | got_signal = 0; |
| 1121 | } |
| 1122 | #else |
| 1123 | if (signal(signals[i], signal_handler) == SIG_IGN) { |
| 1124 | signal(signals[i], SIG_IGN); |
| 1125 | got_signal = 0; |
| 1126 | } |
| 1127 | #endif |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | /* If a signal has arrived, terminate zic with appropriate status. */ |
| 1132 | static void |
| 1133 | check_for_signal(void) |
| 1134 | { |