MCPcopy Create free account
hub / github.com/SNAS/openbmp / signal_handler

Function signal_handler

Server/src/openbmp.cpp:142–177  ·  view source on GitHub ↗

* Signal handler * */

Source from the content-addressed store, hash-verified

140 *
141 */
142void signal_handler(int signum)
143{
144 LOG_NOTICE("Caught signal %d", signum);
145
146 /*
147 * Respond based on the signal
148 */
149 switch (signum) {
150 case SIGTERM :
151 case SIGKILL :
152 case SIGQUIT :
153 case SIGPIPE :
154 case SIGINT :
155 case SIGCHLD : // Handle the child cleanup
156
157 for (size_t i=0; i < thr_list.size(); i++) {
158 if (thr_list.at(i)->running) {
159 pthread_cancel(thr_list.at(i)->thr);
160 thr_list.at(i)->running = false;
161 pthread_join(thr_list.at(i)->thr, NULL);
162 }
163 }
164
165 thr_list.clear();
166
167 LOG_INFO("Done closing all active BMP connections");
168
169 run = false;
170 exit(0);
171 break;
172
173 default:
174 LOG_INFO("Ignoring signal %d", signum);
175 break;
176 }
177}
178
179/**
180 * Parse and handle the command line args

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected