mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00: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:
1 parent
f029ba2111
commit
529b39ebba
3 files changed
+13
-9
No files matched your search
+9
-5
@@ -227,8 +227,11 @@ static void prepare_tty(char *tty, char *procname, int console)
|
|||||||
prctl(PR_SET_NAME, procname, 0, 0, 0);
|
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)
|
if (nowait)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -254,20 +257,21 @@ static int activate_console(int nowait)
|
|||||||
return 0;
|
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_t pid;
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
prepare_tty(tty, "finit-getty", console);
|
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;
|
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;
|
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)
|
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
||||||
_pe("Failed TIOCSCTTY");
|
_pe("Failed TIOCSCTTY");
|
||||||
|
|
||||||
if (activate_console(nowait))
|
if (activate_console(noclear, nowait))
|
||||||
_exit(execv(cmd, args));
|
_exit(execv(cmd, args));
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|||||||
+2
-2
@@ -63,8 +63,8 @@ void set_hostname (char **hostname);
|
|||||||
int complete (char *cmd, int pid);
|
int complete (char *cmd, int pid);
|
||||||
int run (char *cmd);
|
int run (char *cmd);
|
||||||
int run_interactive (char *cmd, char *fmt, ...);
|
int run_interactive (char *cmd, char *fmt, ...);
|
||||||
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 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);
|
||||||
int run_parts (char *dir, char *cmd);
|
int run_parts (char *dir, char *cmd);
|
||||||
|
|
||||||
static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
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)
|
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
|
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)
|
void tty_stop(finit_tty_t *tty)
|
||||||
|
|||||||
Reference in new issue
Block a user