diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2010-05-14 11:13:37 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2010-05-14 11:13:37 +0000 |
commit | 69cfced606e9755ce640af6e463cb96973577377 (patch) | |
tree | 4e1521978a8b2bcf1abe530326fbaa8e89fe3646 /usr.sbin/relayd/relay.c | |
parent | af1420407e436fd56870244a8cf440bd1f534196 (diff) |
allocate all struct event's on the heap, it looks cleaner, feels better
and follows a suggestion in event.h. also don't mix signal() and
signal_set()/signal_add().
ok jsg@ gilles@
Diffstat (limited to 'usr.sbin/relayd/relay.c')
-rw-r--r-- | usr.sbin/relayd/relay.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 00e1f279036..751c35d81e5 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.119 2010/02/18 16:33:25 jsg Exp $ */ +/* $OpenBSD: relay.c,v 1.120 2010/05/14 11:13:36 reyk Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -145,6 +145,14 @@ relay_sig_handler(int sig, short event, void *arg) case SIGTERM: case SIGINT: (void)event_loopexit(NULL); + break; + case SIGCHLD: + case SIGHUP: + case SIGPIPE: + /* ignore */ + break; + default: + fatalx("relay_sig_handler: unexpected signal"); } } @@ -155,8 +163,6 @@ relay(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2], { pid_t pid; struct passwd *pw; - struct event ev_sigint; - struct event ev_sigterm; int i; switch (pid = fork()) { @@ -210,12 +216,17 @@ relay(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2], /* Per-child initialization */ relay_init(); - signal_set(&ev_sigint, SIGINT, relay_sig_handler, NULL); - signal_set(&ev_sigterm, SIGTERM, relay_sig_handler, NULL); - signal_add(&ev_sigint, NULL); - signal_add(&ev_sigterm, NULL); - signal(SIGHUP, SIG_IGN); - signal(SIGPIPE, SIG_IGN); + signal_set(&env->sc_evsigint, SIGINT, relay_sig_handler, env); + signal_set(&env->sc_evsigterm, SIGTERM, relay_sig_handler, env); + signal_set(&env->sc_evsigchld, SIGCHLD, relay_sig_handler, env); + signal_set(&env->sc_evsighup, SIGHUP, relay_sig_handler, env); + signal_set(&env->sc_evsigpipe, SIGPIPE, relay_sig_handler, env); + + signal_add(&env->sc_evsigint, NULL); + signal_add(&env->sc_evsigterm, NULL); + signal_add(&env->sc_evsigchld, NULL); + signal_add(&env->sc_evsighup, NULL); + signal_add(&env->sc_evsigpipe, NULL); /* setup pipes */ close(pipe_pfe2hce[0]); |