aboutsummaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
Diffstat (limited to 'initd')
-rw-r--r--initd/Makemodule.am2
-rw-r--r--initd/init.h10
-rw-r--r--initd/main.c16
-rw-r--r--initd/shutdown.c54
4 files changed, 5 insertions, 77 deletions
diff --git a/initd/Makemodule.am b/initd/Makemodule.am
index 423c8eb..f6fa1da 100644
--- a/initd/Makemodule.am
+++ b/initd/Makemodule.am
@@ -1,5 +1,5 @@
init_SOURCES = initd/main.c initd/runlst.c initd/init.h initd/setup_tty.c
-init_SOURCES += initd/status.c initd/mksock.c initd/shutdown.c initd/svclist.c
+init_SOURCES += initd/status.c initd/mksock.c initd/svclist.c
init_CPPFLAGS = $(AM_CPPFLAGS)
init_CFLAGS = $(AM_CFLAGS)
init_LDFLAGS = $(AM_LDFLAGS)
diff --git a/initd/init.h b/initd/init.h
index dee0b00..826af0f 100644
--- a/initd/init.h
+++ b/initd/init.h
@@ -98,16 +98,6 @@ void print_status(const char *msg, int type, bool update);
*/
int mksock(void);
-/********** shutdown.c **********/
-
-/*
- Kindly tell all processes to go kill themselves, then send
- a SIGKILL if they don't and perform system shutdown.
-
- The argument is passed directly to the reboot() syscall.
-*/
-NORETURN void do_shutdown(int type);
-
/********** svclist.c **********/
/*
diff --git a/initd/main.c b/initd/main.c
index d3e22b6..c4b796c 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -226,18 +226,10 @@ int main(void)
pfd[0].events = pfd[1].events = POLLIN;
for (;;) {
- if (!svclist_have_singleshot()) {
- if (target != runlevel) {
- start_runlevel(target);
- runlevel = target;
- continue;
- }
-
- if (runlevel == TGT_SHUTDOWN)
- do_shutdown(RB_POWER_OFF);
-
- if (runlevel == TGT_REBOOT)
- do_shutdown(RB_AUTOBOOT);
+ if (!svclist_have_singleshot() && target != runlevel) {
+ start_runlevel(target);
+ runlevel = target;
+ continue;
}
ret = poll(pfd, sizeof(pfd) / sizeof(pfd[0]), -1);
diff --git a/initd/shutdown.c b/initd/shutdown.c
deleted file mode 100644
index 1ee68c2..0000000
--- a/initd/shutdown.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * Copyright (C) 2018 - David Oberhollenzer
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <stdio.h>
-#include <errno.h>
-#include <time.h>
-
-#include "init.h"
-
-void do_shutdown(int type)
-{
- struct timespec req, rem;
-
- print_status("sending SIGTERM to all processes", STATUS_WAIT, false);
- kill(-1, SIGTERM);
-
- memset(&req, 0, sizeof(req));
- memset(&rem, 0, sizeof(rem));
- req.tv_sec = 5; /* TODO: make configurable? */
-
- while (nanosleep(&req, &rem) != 0 && errno == EINTR)
- req = rem;
-
- print_status("sending SIGTERM to all processes", STATUS_OK, true);
- kill(-1, SIGKILL);
- print_status("sending SIGKILL to remaining processes",
- STATUS_OK, false);
-
- print_status("sync", STATUS_WAIT, false);
- sync();
- print_status("sync", STATUS_OK, true);
-
- reboot(type);
- perror("reboot system call");
- exit(EXIT_FAILURE);
-}