]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: improve error messages related to halt failures
authorLudwig Nussel <ludwig.nussel@suse.de>
Wed, 9 Feb 2022 09:59:22 +0000 (10:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Feb 2022 10:36:29 +0000 (11:36 +0100)
src/systemctl/systemctl-compat-halt.c
src/systemctl/systemctl-compat-telinit.c

index c8d745592fd4c0a60fdb6670ee7255e7816d1d01..8a0e4e62943d85658580542d611ff55dbe454aaf 100644 (file)
@@ -76,6 +76,7 @@ int halt_parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);
         assert(argv);
 
+        /* called in sysvinit system as last command in shutdown/reboot so this is always forceful */
         if (utmp_get_runlevel(&runlevel, NULL) >= 0)
                 if (IN_SET(runlevel, '0', '6'))
                         arg_force = 2;
@@ -191,5 +192,5 @@ int halt_main(void) {
                 return 0;
 
         r = halt_now(arg_action);
-        return log_error_errno(r, "Failed to reboot: %m");
+        return log_error_errno(r, "Failed to %s: %m", action_table[arg_action].verb);
 }
index c81e9bc3ce33a0cd6b424fd5addbb2cd7ed8588b..0890d6544f616ff042fa3d23cd4f751a60633ebd 100644 (file)
@@ -125,8 +125,11 @@ int telinit_parse_argv(int argc, char *argv[]) {
 }
 
 int start_with_fallback(void) {
+        int r;
+
         /* First, try systemd via D-Bus. */
-        if (start_unit(0, NULL, NULL) == 0)
+        r = start_unit(0, NULL, NULL);
+        if (r == 0)
                 return 0;
 
 #if HAVE_SYSV_COMPAT
@@ -135,8 +138,7 @@ int start_with_fallback(void) {
                 return 0;
 #endif
 
-        return log_error_errno(SYNTHETIC_ERRNO(EIO),
-                               "Failed to talk to init daemon.");
+        return log_error_errno(r, "Failed to talk to init daemon: %m");
 }
 
 int reload_with_fallback(void) {