mirror of
https://github.com/troglobit/finit.git
synced 2026-10-10 16:52:39 +07:00
Simplify, drop SYNC_SHUTDOWN state file, not needed anymore
Similar to 6224166 (previous commit), this old code is a remnant of a
bygone era and not needed anymore.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+17
-16
@@ -281,8 +281,12 @@ static void prepare_tty(char *tty, speed_t speed, char *procname, struct rlimit
|
||||
|
||||
static int activate_console(int noclear, int nowait)
|
||||
{
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
static const char clr[] = "\r\e[2K";
|
||||
static const char cup[] = "\e[A";
|
||||
struct termios orig;
|
||||
int ret = 0;
|
||||
char c;
|
||||
int rc;
|
||||
|
||||
if (nowait || rescue)
|
||||
return 1;
|
||||
@@ -301,27 +305,24 @@ static int activate_console(int noclear, int nowait)
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &c);
|
||||
}
|
||||
|
||||
if (!fexist(SYNC_SHUTDOWN)) {
|
||||
char c;
|
||||
static const char clr[] = "\r\e[2K";
|
||||
static const char cup[] = "\e[A";
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, msg, strlen(msg));
|
||||
while ((rc = read(STDIN_FILENO, &c, 1)) > 0 && c != '\r')
|
||||
continue;
|
||||
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, msg, strlen(msg));
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != '\r')
|
||||
continue;
|
||||
/* On any error (likely EINTR), we avoid starting getty */
|
||||
if (rc == -1)
|
||||
rc = 0;
|
||||
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, cup, strlen(cup));
|
||||
ret = 1;
|
||||
}
|
||||
/* Clear msg and move cursor up for next message/login: */
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, cup, strlen(cup));
|
||||
|
||||
/* Restore TTY */
|
||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig) == -1)
|
||||
ret = 0;
|
||||
rc = 0; /* TTY in bad shape, restart */
|
||||
|
||||
return ret;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -1422,7 +1422,7 @@ void service_monitor(pid_t lost, int status)
|
||||
{
|
||||
svc_t *svc;
|
||||
|
||||
if (fexist(SYNC_SHUTDOWN) || lost <= 1)
|
||||
if (lost <= 1)
|
||||
return;
|
||||
|
||||
svc = svc_find_by_pid(lost);
|
||||
|
||||
@@ -209,8 +209,6 @@ void do_kill(int signo)
|
||||
|
||||
void do_shutdown(shutop_t op)
|
||||
{
|
||||
touch(SYNC_SHUTDOWN);
|
||||
|
||||
if (sdown)
|
||||
run_interactive(sdown, "Calling shutdown hook: %s", sdown);
|
||||
|
||||
@@ -501,9 +499,6 @@ void sig_setup(uev_ctx_t *ctx)
|
||||
|
||||
_d("Setup signals");
|
||||
|
||||
/* Cleanup any stale finit control files */
|
||||
erase(SYNC_SHUTDOWN);
|
||||
|
||||
/*
|
||||
* Standard SysV init calls ctrl-alt-delete handler
|
||||
* We need to disable kernel default so it sends us SIGINT
|
||||
|
||||
Reference in New Issue
Block a user