[PATCH 1/4] Remove loader from the reboot/shutdown/halt picture.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Right now, rebooting/halting after installation is handled in at least
three places:  anaconda knows how to do some things, loader knows how to do
some others, and init knows how to do everything.  loader really just does a
bunch of signal handling and process exit status checking to figure out how
to signal init which is completely unnecessary.  Instead, loader should just
exec anaconda and then get out of the picture.
---
 loader/loader.c |   68 +++---------------------------------------------------
 1 files changed, 4 insertions(+), 64 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index cd3e178..5502553 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -123,9 +123,6 @@ uint64_t flags = LOADER_FLAGS_SELINUX;
 int num_link_checks = 5;
 int post_link_sleep = 0;
 
-static pid_t init_pid = 1;
-static int init_sig = SIGUSR1; /* default to shutdown=halt */
-
 static struct installMethod installMethods[] = {
     { N_("Local CD/DVD"), 0, DEVICE_CDROM, mountCdromImage },
     { N_("Hard drive"), 0, DEVICE_DISK, mountHardDrive },
@@ -1726,11 +1723,6 @@ static void setupBacktrace(void)
     backtrace(&array, 1);
 }
 
-void loaderUsrXHandler(int signum) {
-    logMessage(INFO, "Remembering signal %d\n", signum);
-    init_sig = signum;
-}
-
 static int anaconda_trace_init(void) {
 #ifdef USE_MTRACE
     setenv("MALLOC_TRACE","/malloc",1);
@@ -1802,26 +1794,6 @@ int main(int argc, char ** argv) {
         { NULL },
     };
 
-    /* get init PID if we have it */
-    if ((f = fopen("/var/run/init.pid", "r")) != NULL) {
-        char linebuf[256];
-        memset(linebuf, '\0', sizeof(linebuf));
-
-        while (fgets(linebuf, sizeof(linebuf) - 1, f) != NULL) {
-            errno = 0;
-            init_pid = strtol((const char *) &linebuf, NULL, 10);
-            if (errno == EINVAL || errno == ERANGE) {
-                logMessage(ERROR, "%s (%d): %m", __func__, __LINE__);
-                init_pid = 1;
-            }
-        }
-
-        fclose(f);
-    }
-
-    signal(SIGUSR1, loaderUsrXHandler);
-    signal(SIGUSR2, loaderUsrXHandler);
-
     /* Make sure sort order is right. */
     setenv ("LC_COLLATE", "C", 1);	
 
@@ -2253,7 +2225,6 @@ int main(int argc, char ** argv) {
     closeLog();
     
     if (!FL_TESTING(flags)) {
-        int pid, status, rc;
         char *fmt;
 
         if (FL_RESCUE(flags)) {
@@ -2263,44 +2234,13 @@ int main(int argc, char ** argv) {
         }
         printf(fmt, VERSION, getProductName());
 
-        if (!(pid = fork())) {
-            if (execv(anacondaArgs[0], anacondaArgs) == -1) {
-               fprintf(stderr,"exec of anaconda failed: %m\n");
-               doExit(1);
-            }
-        }
-
-        waitpid(pid, &status, 0);
-
-        if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status))) {
-            rc = 1;
-        } else {
-            rc = 0;
-        }
-
-        if ((rc == 0) && (FL_POWEROFF(flags) || FL_HALT(flags))) {
-            if (!(pid = fork())) {
-                char * cmd = (FL_POWEROFF(flags) ? strdup("/sbin/poweroff") :
-                              strdup("/sbin/halt"));
-                if (execl(cmd, cmd, NULL) == -1) {
-                    fprintf(stderr, "exec of poweroff failed: %m\n");
-                    doExit(1);
-                }
-            }
-            waitpid(pid, &status, 0);
+        if (execv(anacondaArgs[0], anacondaArgs) == -1) {
+           fprintf(stderr,"exec of anaconda failed: %m\n");
+           doExit(1);
         }
-
-        stop_fw_loader(&loaderData);
-#if defined(__s390__) || defined(__s390x__)
-        /* at the latest possibility signal init=linuxrc.s390 to reboot/halt */
-        logMessage(INFO, "Sending signal %d to process %d\n",
-                   init_sig, init_pid);
-        kill(init_pid, init_sig);
-#endif
-        doExit(rc);
     }
 
-    doExit(1);
+    return 0;
 }
 
 /* vim:set sw=4 sts=4 et: */
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux