mirror of
https://github.com/troglobit/finit.git
synced 2026-10-25 12:04:36 +00:00
Fix #79: Add 'nowait' option to tty setting, external getty
This patch makes it possible to disable the "Please press Enter" prompt when using an external getty. Simply append `nowait` to the .conf entry and Finit will spawn the getty immediately. A future patch will add support for `noclear` as well to external getty, as well as a change in default (=> `wait`) for the built-in getty. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
2fe257b7af
commit
f273ecc135
4 files changed
+56
-35
No files matched your search
+29
-18
@@ -240,7 +240,34 @@ pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console)
|
||||
return pid;
|
||||
}
|
||||
|
||||
pid_t run_getty2(char *tty, char *cmd, char *args[], int console)
|
||||
static int activate_console(int nowait)
|
||||
{
|
||||
if (nowait)
|
||||
return 1;
|
||||
|
||||
while (!fexist(SYNC_SHUTDOWN)) {
|
||||
char c;
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
|
||||
if (fexist(SYNC_STOPPED)) {
|
||||
sleep(5);
|
||||
continue;
|
||||
}
|
||||
|
||||
(void)write(STDERR_FILENO, msg, sizeof(msg));
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != '\n')
|
||||
continue;
|
||||
|
||||
if (fexist(SYNC_STOPPED))
|
||||
continue;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
pid_t run_getty2(char *tty, char *cmd, char *args[], int nowait, int console)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
@@ -274,24 +301,8 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int console)
|
||||
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
||||
_pe("Failed TIOCSCTTY");
|
||||
|
||||
while (!fexist(SYNC_SHUTDOWN)) {
|
||||
char c;
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
|
||||
if (fexist(SYNC_STOPPED)) {
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
(void)write(STDERR_FILENO, msg, sizeof(msg));
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != '\n')
|
||||
continue;
|
||||
|
||||
if (fexist(SYNC_STOPPED))
|
||||
continue;
|
||||
|
||||
if (activate_console(nowait))
|
||||
_exit(execv(cmd, args));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
vhangup();
|
||||
|
||||
Reference in new issue
Block a user