mirror of
https://github.com/troglobit/finit.git
synced 2026-10-11 17:02:42 +07:00
tty: Add 'noclear' + 'nowait' options to built-in and external tty's
This patch aligns the two tty configuration stanzas, thus clear and wait
are now the default for both.
tty [LVLS] <DEV> [BAUD] [noclear] [nowait] [TERM]
tty [LVLS] <CMD> <ARGS> [noclear] [nowait]
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+9
-5
@@ -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);
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user