summaryrefslogtreecommitdiff
path: root/usr.sbin/switchd
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@cvs.openbsd.org>2016-09-15 15:52:23 +0000
committerRafael Zalamena <rzalamena@cvs.openbsd.org>2016-09-15 15:52:23 +0000
commit8f2f9e95a17e27ccb25201f4fedfa9808b47d510 (patch)
treef03a3c4fac50180a1ca5b6ca2a08eaf5c9d9c234 /usr.sbin/switchd
parentdc2b5073a2d4ecb60233dd99ec8b4b5dcc4aaf7b (diff)
Teach switchd(8) how to shutdown using close() instead of kill().
This commit mostly removes the parent SIGCHLD handler, the rest of the code is already in proc.c. ok reyk@
Diffstat (limited to 'usr.sbin/switchd')
-rw-r--r--usr.sbin/switchd/switchd.c48
1 files changed, 3 insertions, 45 deletions
diff --git a/usr.sbin/switchd/switchd.c b/usr.sbin/switchd/switchd.c
index 1343884e29a..45311dad0b4 100644
--- a/usr.sbin/switchd/switchd.c
+++ b/usr.sbin/switchd/switchd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchd.c,v 1.8 2016/09/14 13:46:51 rzalamena Exp $ */
+/* $OpenBSD: switchd.c,v 1.9 2016/09/15 15:52:22 rzalamena Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
@@ -20,7 +20,6 @@
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/queue.h>
-#include <sys/wait.h>
#include <arpa/inet.h>
#include <netinet/in.h>
@@ -199,21 +198,19 @@ main(int argc, char *argv[])
* dns - for resolving host in the configuration files.
* sendfd - send sockets to child processes on reload.
*/
- if (pledge("stdio rpath wpath inet dns proc sendfd", NULL) == -1)
+ if (pledge("stdio rpath wpath inet dns sendfd", NULL) == -1)
fatal("pledge");
event_init();
signal_set(&ps->ps_evsigint, SIGINT, parent_sig_handler, ps);
signal_set(&ps->ps_evsigterm, SIGTERM, parent_sig_handler, ps);
- signal_set(&ps->ps_evsigchld, SIGCHLD, parent_sig_handler, ps);
signal_set(&ps->ps_evsighup, SIGHUP, parent_sig_handler, ps);
signal_set(&ps->ps_evsigpipe, SIGPIPE, parent_sig_handler, ps);
signal_set(&ps->ps_evsigusr1, SIGUSR1, parent_sig_handler, ps);
signal_add(&ps->ps_evsigint, NULL);
signal_add(&ps->ps_evsigterm, NULL);
- signal_add(&ps->ps_evsigchld, NULL);
signal_add(&ps->ps_evsighup, NULL);
signal_add(&ps->ps_evsigpipe, NULL);
signal_add(&ps->ps_evsigusr1, NULL);
@@ -303,9 +300,6 @@ void
parent_sig_handler(int sig, short event, void *arg)
{
struct privsep *ps = arg;
- int die = 0, status, fail, id;
- pid_t pid;
- char *cause;
switch (sig) {
case SIGHUP:
@@ -325,43 +319,7 @@ parent_sig_handler(int sig, short event, void *arg)
break;
case SIGTERM:
case SIGINT:
- die = 1;
- /* FALLTHROUGH */
- case SIGCHLD:
- do {
- pid = waitpid(-1, &status, WNOHANG);
- if (pid <= 0)
- continue;
-
- fail = 0;
- if (WIFSIGNALED(status)) {
- fail = 1;
- asprintf(&cause, "terminated; signal %d",
- WTERMSIG(status));
- } else if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0) {
- fail = 1;
- asprintf(&cause, "exited abnormally");
- } else
- asprintf(&cause, "exited okay");
- } else
- fatalx("unexpected cause of SIGCHLD");
-
- die = 1;
-
- for (id = 0; id < PROC_MAX; id++)
- if (pid == ps->ps_pid[id]) {
- if (fail)
- log_warnx("lost child: %s %s",
- ps->ps_title[id], cause);
- break;
- }
-
- free(cause);
- } while (pid > 0 || (pid == -1 && errno == EINTR));
-
- if (die)
- parent_shutdown(ps->ps_env);
+ parent_shutdown(ps->ps_env);
break;
default:
fatalx("unexpected signal");