diff --git a/src/exec.c b/src/exec.c index dc07a828..fe712135 100644 --- a/src/exec.c +++ b/src/exec.c @@ -227,8 +227,11 @@ static void prepare_tty(char *tty, char *procname, int console) prctl(PR_SET_NAME, procname, 0, 0, 0); } -static int activate_console(int nowait) +static int activate_console(int noclear, int nowait) { + if (!noclear) + (void)write(STDERR_FILENO, "\e[r\e[H\e[J", 9); + if (nowait) return 1; @@ -254,20 +257,21 @@ static int activate_console(int nowait) return 0; } -pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console) +pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait, int console) { pid_t pid; pid = fork(); if (!pid) { prepare_tty(tty, "finit-getty", console); - _exit(getty(tty, speed, term, NULL)); + if (activate_console(noclear, nowait)) + _exit(getty(tty, speed, term, NULL)); } return pid; } -pid_t run_getty2(char *tty, char *cmd, char *args[], int nowait, int console) +pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, int console) { pid_t pid; @@ -301,7 +305,7 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int nowait, int console) if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0) _pe("Failed TIOCSCTTY"); - if (activate_console(nowait)) + if (activate_console(noclear, nowait)) _exit(execv(cmd, args)); close(fd); diff --git a/src/helpers.h b/src/helpers.h index 142a3d3d..c59c1ed5 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -63,8 +63,8 @@ void set_hostname (char **hostname); int complete (char *cmd, int pid); int run (char *cmd); int run_interactive (char *cmd, char *fmt, ...); -pid_t run_getty (char *tty, char *speed, char *term, int noclear, int console); -pid_t run_getty2 (char *tty, char *cmd, char *args[], int nowait, int console); +pid_t run_getty (char *tty, char *speed, char *term, int noclear, int nowait, int console); +pid_t run_getty2 (char *tty, char *cmd, char *args[], int noclear, int nowait, int console); int run_parts (char *dir, char *cmd); static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid) diff --git a/src/tty.c b/src/tty.c index bbe1af48..5290b23d 100644 --- a/src/tty.c +++ b/src/tty.c @@ -381,9 +381,9 @@ void tty_start(finit_tty_t *tty) } if (!tty->cmd) - tty->pid = run_getty(dev, tty->baud, tty->term, tty->noclear, is_console); + tty->pid = run_getty(dev, tty->baud, tty->term, tty->noclear, tty->nowait, is_console); else - tty->pid = run_getty2(dev, tty->cmd, tty->args, tty->nowait, is_console); + tty->pid = run_getty2(dev, tty->cmd, tty->args, tty->noclear, tty->nowait, is_console); } void tty_stop(finit_tty_t *tty)