diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 11:56:24 +0100 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 11:56:24 +0100 |
commit | 78aa1577a26a45ccc2403948ac87db3842a7c07d (patch) | |
tree | 4572a6d473c9dc3081be6fffcc08f0515fee7233 /glougloud/glougloud.c | |
parent | update roadmap for 0.4 (diff) | |
download | glouglou-78aa1577a26a45ccc2403948ac87db3842a7c07d.tar.xz glouglou-78aa1577a26a45ccc2403948ac87db3842a7c07d.zip |
correctly handle signals
Diffstat (limited to 'glougloud/glougloud.c')
-rw-r--r-- | glougloud/glougloud.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/glougloud/glougloud.c b/glougloud/glougloud.c index 95a32ef..5e290ae 100644 --- a/glougloud/glougloud.c +++ b/glougloud/glougloud.c @@ -51,7 +51,8 @@ sig_handler(int sig, short why, void *data) int main(int argc, char **argv) { - int loglevel = 0; + struct event *ev_sigint, *ev_sigterm, *ev_sigchld, *ev_sighup; + int loglevel = 0; int op; while ((op = getopt(argc, argv, "hv")) != -1) { @@ -70,6 +71,16 @@ main(int argc, char **argv) ev_base = event_base_new(); + ev_sigint = evsignal_new(ev_base, SIGINT, sig_handler, NULL); + ev_sigterm = evsignal_new(ev_base, SIGTERM, sig_handler, NULL); + ev_sigchld = evsignal_new(ev_base, SIGCHLD, sig_handler, NULL); + ev_sighup = evsignal_new(ev_base, SIGHUP, sig_handler, NULL); + evsignal_add(ev_sigint, NULL); + evsignal_add(ev_sigterm, NULL); + evsignal_add(ev_sigchld, NULL); + evsignal_add(ev_sighup, NULL); + signal(SIGPIPE, SIG_IGN); + ggserv_probes = gg_server_start(ev_base, "127.0.0.1", 4430, prb_handle_conn, prb_handle_packet, NULL); ggserv_clients = gg_server_start(ev_base, "127.0.0.1", 4431, |