#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 */
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;
// 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();
if (am_system_init) {
log(LogLevel::INFO, " No more active services.");
- if (reboot) {
+ if (do_reboot) {
cout << " Will reboot.";
}
else if (got_sigterm) {
}
if (am_system_init) {
- if (reboot) {
+ if (do_reboot) {
// TODO log error from fork
if (fork() == 0) {
execl("/sbin/reboot", "/sbin/reboot", (char *) 0);
/* 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();
}