Rename 'reboot' variable to 'do_reboot' to avoid conflict with OpenBSD
authorDavin McCall <davmac@davmac.org>
Tue, 17 Nov 2015 23:11:50 +0000 (23:11 +0000)
committerDavin McCall <davmac@davmac.org>
Tue, 17 Nov 2015 23:11:50 +0000 (23:11 +0000)
'reboot' function.

dinit.cc

index 31a6fe4e9a5e4d355855fef1873467a9aefacc05..b39d7d63668831e501b5b36389921345e562443d 100644 (file)
--- a/dinit.cc
+++ b/dinit.cc
 #include "control.h"
 #include "dinit-log.h"
 
+#ifdef __linux__
+#include <sys/klog.h>
+#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<const char *>::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();
 }