damnit.
[oweals/busybox.git] / init.c
diff --git a/init.c b/init.c
index dbd9f281211342f0d16faa398915e2eb945fd504..3c800b9b2ad8bc7acdd87d1e09865e2affc24903 100644 (file)
--- a/init.c
+++ b/init.c
@@ -151,19 +151,11 @@ void message(int device, char *fmt, ...)
 void set_term( int fd)
 {
     struct termios tty;
-#if 0
-    static const char control_characters[] = {
-       '\003', '\034', '\177', '\030', '\004', '\0',
-       '\1', '\0', '\021', '\023', '\032', '\0', '\022',
-       '\017', '\027', '\026', '\0'
-       };
-#else  
     static const char control_characters[] = {
        '\003', '\034', '\177', '\025', '\004', '\0',
        '\1', '\0', '\021', '\023', '\032', '\0', '\022',
        '\017', '\027', '\026', '\0'
        };
-#endif
 
     tcgetattr(fd, &tty);
 
@@ -344,9 +336,9 @@ static pid_t run(const char * const* command,
        }
 
        /* Log the process name and args */
-       message(LOG, "Starting pid %d, console %s: '", getpid(), terminal);
-       while ( *cmd) message(LOG, "%s ", *cmd++);
-       message(LOG, "'\r\n");
+       message(LOG|CONSOLE, "Starting pid %d, console %s: '", getpid(), terminal);
+       while ( *cmd) message(LOG|CONSOLE, "%s ", *cmd++);
+       message(LOG|CONSOLE, "'\r\n");
        
        /* Now run it.  The new program will take over this PID, 
         * so nothing further in init.c should be run. */
@@ -386,7 +378,7 @@ goodnight:
 static void shutdown_system(void)
 {
     const char* const swap_off_cmd[] = { "swapoff", "swapoff", "-a", 0};
-    const char* const umount_cmd[] = { "umount", "umount", "-a", "-n", 0};
+    const char* const umount_cmd[] = { "umount", "umount", "-a", 0};
 
 #ifndef DEBUG_INIT
     /* Allow Ctrl-Alt-Del to reboot system. */
@@ -426,9 +418,10 @@ static void halt_signal(int sig)
            "The system is halted. Press CTRL-ALT-DEL or turn off power\r\n");
     sync();
 #ifndef DEBUG_INIT
-    while (1) sleep(1);
-    reboot(RB_HALT_SYSTEM);
-    //reboot(RB_POWER_OFF);
+    if (sig == SIGUSR2)
+       reboot(RB_POWER_OFF);
+    else
+       reboot(RB_HALT_SYSTEM);
 #endif
     exit(0);
 }
@@ -438,7 +431,6 @@ static void reboot_signal(int sig)
     shutdown_system();
     message(CONSOLE, "Please stand by while rebooting the system.\r\n");
     sync();
-    while (1) sleep(1);
 #ifndef DEBUG_INIT
     reboot(RB_AUTOBOOT);
 #endif
@@ -524,8 +516,11 @@ extern int init_main(int argc, char **argv)
     } else
        message(CONSOLE|LOG, "Mounting /proc: failed!\n");
 
+fprintf(stderr, "got proc\n");
+
     /* Make sure there is enough memory to do something useful. */
     check_memory();
+fprintf(stderr, "got check_memory\n");
 
     /* Check if we are supposed to be in single user mode */
     if ( argc > 1 && (!strcmp(argv[1], "single") || 
@@ -534,6 +529,7 @@ extern int init_main(int argc, char **argv)
        tty1_command = shell_command;
        tty2_command = shell_command;
     }
+fprintf(stderr, "got single\n");
 
     /* Make sure an init script exists before trying to run it */
     if (single==FALSE && stat(INITSCRIPT, &statbuf)==0) {
@@ -545,6 +541,7 @@ extern int init_main(int argc, char **argv)
     /* Make sure /sbin/getty exists before trying to run it */
     if (stat(GETTY, &statbuf)==0) {
        char* where;
+fprintf(stderr, "\n");
        wait_for_enter_tty2 = FALSE;
        where = strrchr( console, '/');
        if ( where != NULL) {