summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/hce.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2010-05-14 11:13:37 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2010-05-14 11:13:37 +0000
commit69cfced606e9755ce640af6e463cb96973577377 (patch)
tree4e1521978a8b2bcf1abe530326fbaa8e89fe3646 /usr.sbin/relayd/hce.c
parentaf1420407e436fd56870244a8cf440bd1f534196 (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/hce.c')
-rw-r--r--usr.sbin/relayd/hce.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index 96a8aac9141..2eb5601d160 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.54 2010/01/11 06:40:14 jsg Exp $ */
+/* $OpenBSD: hce.c,v 1.55 2010/05/14 11:13:36 reyk Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -62,6 +62,11 @@ hce_sig_handler(int sig, short event, void *arg)
case SIGTERM:
hce_shutdown();
break;
+ case SIGCHLD:
+ case SIGHUP:
+ case SIGPIPE:
+ /* ignore */
+ break;
default:
fatalx("hce_sig_handler: unexpected signal");
}
@@ -75,8 +80,6 @@ hce(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
pid_t pid;
struct passwd *pw;
int i;
- struct event ev_sigint;
- struct event ev_sigterm;
switch (pid = fork()) {
case -1:
@@ -135,12 +138,17 @@ hce(struct relayd *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2],
iev_main->handler, iev_main);
event_add(&iev_main->ev, NULL);
- signal_set(&ev_sigint, SIGINT, hce_sig_handler, NULL);
- signal_set(&ev_sigterm, SIGTERM, hce_sig_handler, NULL);
- signal_add(&ev_sigint, NULL);
- signal_add(&ev_sigterm, NULL);
- signal(SIGPIPE, SIG_IGN);
- signal(SIGHUP, SIG_IGN);
+ signal_set(&env->sc_evsigint, SIGINT, hce_sig_handler, env);
+ signal_set(&env->sc_evsigterm, SIGTERM, hce_sig_handler, env);
+ signal_set(&env->sc_evsigchld, SIGCHLD, hce_sig_handler, env);
+ signal_set(&env->sc_evsighup, SIGHUP, hce_sig_handler, env);
+ signal_set(&env->sc_evsigpipe, SIGPIPE, hce_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[1]);