Remove gratuitous and unnecessary "BusyBox" refernece in login prompt
[oweals/busybox.git] / init / init.c
index 989babff7f0d69766040670cdadda8dc3f616eac..79ab78fc240f23d09e4d1395d7e1518744d5d753 100644 (file)
@@ -232,6 +232,8 @@ static void message(int device, char *fmt, ...)
                        log_fd = -2;
                        fprintf(stderr, "Bummer, can't write to log on %s!\n", log);
                        device = CONSOLE;
+               } else {
+                       fcntl(log_fd, F_SETFD, FD_CLOEXEC);
                }
        }
        if ((device & LOG) && (log_fd >= 0)) {
@@ -499,12 +501,11 @@ static pid_t run(struct init_action *a)
                signal(SIGTSTP, SIG_DFL);
 
                /* Create a new session and make ourself the process
-                * group leader for non-interactive jobs */
-               if ((a->action & (RESPAWN)) == 0)
-                       setsid();
+                * group leader */
+               setsid();
 
                /* Open the new terminal device */
-               if ((device_open(a->terminal, O_RDWR | O_NOCTTY)) < 0) {
+               if ((device_open(a->terminal, O_RDWR)) < 0) {
                        if (stat(a->terminal, &sb) != 0) {
                                message(LOG | CONSOLE, "\rdevice '%s' does not exist.\n",
                                                a->terminal);
@@ -514,10 +515,6 @@ static pid_t run(struct init_action *a)
                        _exit(1);
                }
 
-               /* Non-interactive jobs should not get a controling tty */
-               if ((a->action & (RESPAWN)) == 0)
-                       (void) ioctl(0, TIOCSCTTY, 0);
-
                /* Make sure the terminal will act fairly normal for us */
                set_term(0);
                /* Setup stdout, stderr for the new process so
@@ -525,11 +522,6 @@ static pid_t run(struct init_action *a)
                dup(0);
                dup(0);
 
-               /* For interactive jobs, create a new session 
-                * and become the process group leader */
-               if ((a->action & (RESPAWN)))
-                       setsid();
-
                /* If the init Action requires us to wait, then force the
                 * supplied terminal to be the controlling tty. */
                if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {
@@ -635,6 +627,7 @@ static pid_t run(struct init_action *a)
                        messageND(LOG,
                                          "Waiting for enter to start '%s' (pid %d, terminal %s)\n",
                                          cmdpath, getpid(), a->terminal);
+                       fflush(stdout);
                        write(fileno(stdout), press_enter, sizeof(press_enter) - 1);
                        getc(stdin);
                }
@@ -658,8 +651,7 @@ static pid_t run(struct init_action *a)
                execve(cmdpath, cmd, environment);
 
                /* We're still here?  Some error happened. */
-               message(LOG | CONSOLE, "\rBummer, could not run '%s': %s\n", cmdpath,
-                               strerror(errno));
+               message(LOG | CONSOLE, "\rBummer, could not run '%s': %m\n", cmdpath);
                _exit(-1);
        }
        sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -691,8 +683,7 @@ static void run_actions(int action)
        for (a = init_action_list; a; a = tmp) {
                tmp = a->next;
                if (a->action == action) {
-                       if (a->
-                               action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {
+                       if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {
                                waitfor(a);
                                delete_init_action(a);
                        } else if (a->action & ONCE) {
@@ -783,8 +774,8 @@ static void exec_signal(int sig)
                        message(CONSOLE | LOG, "\rTrying to re-exec %s\n", a->command);
                        execl(a->command, a->command, NULL);
 
-                       message(CONSOLE | LOG, "\rexec of '%s' failed: %s\n",
-                                       a->command, strerror(errno));
+                       message(CONSOLE | LOG, "\rexec of '%s' failed: %m\n",
+                                       a->command);
                        sync();
                        sleep(2);
                        init_reboot(RB_HALT_SYSTEM);