From 0ae70d125302079b57f6e4abdd963852a78d85e4 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 17 Nov 2015 23:11:50 +0000 Subject: [PATCH] Rename 'reboot' variable to 'do_reboot' to avoid conflict with OpenBSD 'reboot' function. --- dinit.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dinit.cc b/dinit.cc index 31a6fe4..b39d7d6 100644 --- a/dinit.cc +++ b/dinit.cc @@ -14,6 +14,10 @@ #include "control.h" #include "dinit-log.h" +#ifdef __linux__ +#include +#endif + /* TODO: prevent services from respawning too quickly */ /* TODO: optional automatic restart of services */ @@ -61,7 +65,7 @@ static bool got_sigterm = false; static ServiceSet *service_set; static bool am_system_init = false; // true if we are the system init process -static bool reboot = false; // whether to reboot (instead of halting) +static bool do_reboot = false; // whether to reboot (instead of halting) static bool control_socket_open = false; @@ -182,6 +186,13 @@ int main(int argc, char **argv) // Try to open control socket (may fail due to readonly filesystem) open_control_socket(loop); +#ifdef __linux__ + if (am_system_init) { + // Disable non-critical kernel output to console + klogctl(6 /* SYSLOG_ACTION_CONSOLE_OFF */, nullptr, 0); + } +#endif + /* start requested services */ service_set = new ServiceSet(service_dir); for (list::iterator i = services_to_start.begin(); @@ -207,7 +218,7 @@ int main(int argc, char **argv) if (am_system_init) { log(LogLevel::INFO, " No more active services."); - if (reboot) { + if (do_reboot) { cout << " Will reboot."; } else if (got_sigterm) { @@ -220,7 +231,7 @@ int main(int argc, char **argv) } if (am_system_init) { - if (reboot) { + if (do_reboot) { // TODO log error from fork if (fork() == 0) { execl("/sbin/reboot", "/sbin/reboot", (char *) 0); @@ -330,7 +341,7 @@ void open_control_socket(struct ev_loop *loop) /* handle SIGINT signal (generated by kernel when ctrl+alt+del pressed) */ static void sigint_reboot_cb(struct ev_loop *loop, ev_signal *w, int revents) { - reboot = true; + do_reboot = true; log_to_console = true; service_set->stop_all_services(); } -- 2.25.1