mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
Refactor TTY exec, prepare for external getty
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
fefa6a93ca
commit
b629348973
1 file changed
+18
-8
+18
-8
@@ -212,12 +212,8 @@ int run_interactive(char *cmd, char *fmt, ...)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console)
|
static void prepare_tty(char *tty, char *procname, int console)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
pid = fork();
|
|
||||||
if (!pid) {
|
|
||||||
/* Reset signal handlers that were set by the parent process */
|
/* Reset signal handlers that were set by the parent process */
|
||||||
sig_unblock();
|
sig_unblock();
|
||||||
setsid();
|
setsid();
|
||||||
@@ -226,17 +222,31 @@ pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console)
|
|||||||
utmp_set_init(tty, 0);
|
utmp_set_init(tty, 0);
|
||||||
|
|
||||||
if (console)
|
if (console)
|
||||||
prctl(PR_SET_NAME, "console", 0, 0, 0);
|
procname = "console";
|
||||||
else
|
prctl(PR_SET_NAME, procname, 0, 0, 0);
|
||||||
prctl(PR_SET_NAME, "finit-getty", 0, 0, 0);
|
}
|
||||||
|
|
||||||
|
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int console)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if (!pid) {
|
||||||
|
prepare_tty(tty, "finit-getty", console);
|
||||||
_exit(getty(tty, speed, term, noclear, NULL));
|
_exit(getty(tty, speed, term, noclear, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
/* Reset signal handlers that were set by the parent process */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
int run_parts(char *dir, char *cmd)
|
int run_parts(char *dir, char *cmd)
|
||||||
{
|
{
|
||||||
struct dirent **e;
|
struct dirent **e;
|
||||||
|
|||||||
Reference in new issue
Block a user