]> err.no Git - systemd/commitdiff
main: only fall back to /bin/sh in case /sbin/init does not exist
authorKay Sievers <kay@vrfy.org>
Tue, 22 May 2012 17:11:10 +0000 (19:11 +0200)
committerKay Sievers <kay@vrfy.org>
Tue, 22 May 2012 17:17:40 +0000 (19:17 +0200)
src/core/main.c

index b66ae0e035f1e31c9c8207157ce41287cd01bcf3..4d9a2d453ea51d8c9cfa19a6137bb91ec22fd93e 100644 (file)
@@ -1749,12 +1749,15 @@ finish:
                 args[0] = "/sbin/init";
                 execv(args[0], (char* const*) args);
 
-                log_warning("Failed to execute /sbin/init, trying fallback: %m");
+                if (errno == ENOENT) {
+                        log_warning("No /sbin/init, trying fallback");
 
-                args[0] = "/bin/sh";
-                args[1] = NULL;
-                execv(args[0], (char* const*) args);
-                log_error("Failed to execute /bin/sh, giving up: %m");
+                        args[0] = "/bin/sh";
+                        args[1] = NULL;
+                        execv(args[0], (char* const*) args);
+                        log_error("Failed to execute /bin/sh, giving up: %m");
+                } else
+                        log_warning("Failed to execute /sbin/init, giving up: %m");
         }
 
         if (serialization)