Browse Source

* merge signal handlers

master
Alex 'AdUser' Z 9 years ago
parent
commit
c6370906be
  1. 21
      src/main.c

21
src/main.c

@ -33,15 +33,20 @@ struct {
enum { stop = 0, run, reconfig, test } state = run;
void sa_term(int signum) {
UNUSED(signum);
void signal_handler(int signum) {
switch (signum) {
case SIGTERM:
case SIGINT:
f2b_log_msg(log_info, "got SIGTERM/SIGINT, exiting");
state = stop;
}
void sa_hup(int signum) {
UNUSED(signum);
break;
case SIGHUP:
f2b_log_msg(log_note, "got SIGHUP, reloading config");
state = reconfig;
break;
default:
break;
}
}
#define SA_REGISTER(SIGNUM, HANDLER) \
@ -139,9 +144,9 @@ int main(int argc, char *argv[]) {
}
}
SA_REGISTER(SIGTERM, &sa_term);
SA_REGISTER(SIGINT, &sa_term);
SA_REGISTER(SIGHUP, &sa_hup);
SA_REGISTER(SIGTERM, &signal_handler);
SA_REGISTER(SIGINT, &signal_handler);
SA_REGISTER(SIGHUP, &signal_handler);
if (opts.config_path[0] == '\0')
usage(EXIT_FAILURE);

Loading…
Cancel
Save