Adjust dependency auto-break logic.
[oweals/dinit.git] / src / dinit.cc
index c865211e2d37bf566430e28bb81d1606fc75b08d..b7fe727a007ecb7f2bae19fe303d160d9fddc2c9 100644 (file)
@@ -484,9 +484,10 @@ int dinit_main(int argc, char **argv)
         }
         
         // Fork and execute dinit-reboot.
-        const char *shutdown_exec = literal(SBINDIR) + "/shutdown";
-        execl(shutdown_exec, shutdown_exec, "--system", cmd_arg, nullptr);
-        log(loglevel_t::ERROR, literal("Could not execute ") + SBINDIR + "/shutdown: ", strerror(errno));
+        constexpr auto shutdown_exec = literal(SBINDIR) + "/shutdown";
+        execl(shutdown_exec.c_str(), shutdown_exec.c_str(), "--system", cmd_arg, nullptr);
+        log(loglevel_t::ERROR, (literal("Could not execute ") + SBINDIR + "/shutdown: ").c_str(),
+                strerror(errno));
         
         // PID 1 must not actually exit, although we should never reach this point:
         while (true) {
@@ -703,6 +704,7 @@ void setup_external_log() noexcept
                 // basically use it anyway.
                 try {
                     setup_main_log(sockfd);
+                    external_log_open = true;
                 }
                 catch (std::exception &e) {
                     log(loglevel_t::ERROR, "Setting up log failed: ", e.what());
@@ -723,6 +725,7 @@ void setup_external_log() noexcept
             if (log_fd >= 0) {
                 try {
                     setup_main_log(log_fd);
+                    external_log_open = true;
                 }
                 catch (std::exception &e) {
                     log(loglevel_t::ERROR, "Setting up log failed: ", e.what());
@@ -748,8 +751,8 @@ static void sigquit_cb(eventloop_t &eloop) noexcept
 {
     // This performs an immediate shutdown, without service rollback.
     close_control_socket();
-    const char *shutdown_exec = literal(SBINDIR) + "/shutdown";
-    execl(shutdown_exec, shutdown_exec, "--system", (char *) 0);
+    constexpr auto shutdown_exec = literal(SBINDIR) + "/shutdown";
+    execl(shutdown_exec.c_str(), shutdown_exec.c_str(), "--system", (char *) 0);
     log(loglevel_t::ERROR, literal("Error executing ") + SBINDIR + "/sbin/shutdown: ", strerror(errno));
     sync(); // since a hard poweroff might be required at this point...
 }