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:
Joachim Wiberg committed 2021-06-03 12:51:59 +02:00
1 parent 62241668df
commit e8f5ec2579
4 files changed
+18 -24

No files matched your search

+17 -16
View File
@@ -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 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; struct termios orig;
int ret = 0; char c;
int rc;
if (nowait || rescue) if (nowait || rescue)
return 1; return 1;
@@ -301,27 +305,24 @@ static int activate_console(int noclear, int nowait)
tcsetattr(STDIN_FILENO, TCSAFLUSH, &c); tcsetattr(STDIN_FILENO, TCSAFLUSH, &c);
} }
if (!fexist(SYNC_SHUTDOWN)) { dprint(STDERR_FILENO, clr, strlen(clr));
char c; dprint(STDERR_FILENO, msg, strlen(msg));
static const char clr[] = "\r\e[2K"; while ((rc = read(STDIN_FILENO, &c, 1)) > 0 && c != '\r')
static const char cup[] = "\e[A"; continue;
static const char msg[] = "\nPlease press Enter to activate this console.";
dprint(STDERR_FILENO, clr, strlen(clr)); /* On any error (likely EINTR), we avoid starting getty */
dprint(STDERR_FILENO, msg, strlen(msg)); if (rc == -1)
while (read(STDIN_FILENO, &c, 1) == 1 && c != '\r') rc = 0;
continue;
dprint(STDERR_FILENO, clr, strlen(clr)); /* Clear msg and move cursor up for next message/login: */
dprint(STDERR_FILENO, cup, strlen(cup)); dprint(STDERR_FILENO, clr, strlen(clr));
ret = 1; dprint(STDERR_FILENO, cup, strlen(cup));
}
/* Restore TTY */ /* Restore TTY */
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig) == -1) if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig) == -1)
ret = 0; rc = 0; /* TTY in bad shape, restart */
return ret; return rc;
} }
/* /*
+1 -1
View File
@@ -1422,7 +1422,7 @@ void service_monitor(pid_t lost, int status)
{ {
svc_t *svc; svc_t *svc;
if (fexist(SYNC_SHUTDOWN) || lost <= 1) if (lost <= 1)
return; return;
svc = svc_find_by_pid(lost); svc = svc_find_by_pid(lost);
-5
View File
@@ -209,8 +209,6 @@ void do_kill(int signo)
void do_shutdown(shutop_t op) void do_shutdown(shutop_t op)
{ {
touch(SYNC_SHUTDOWN);
if (sdown) if (sdown)
run_interactive(sdown, "Calling shutdown hook: %s", sdown); run_interactive(sdown, "Calling shutdown hook: %s", sdown);
@@ -501,9 +499,6 @@ void sig_setup(uev_ctx_t *ctx)
_d("Setup signals"); _d("Setup signals");
/* Cleanup any stale finit control files */
erase(SYNC_SHUTDOWN);
/* /*
* Standard SysV init calls ctrl-alt-delete handler * Standard SysV init calls ctrl-alt-delete handler
* We need to disable kernel default so it sends us SIGINT * We need to disable kernel default so it sends us SIGINT
-2
View File
@@ -28,8 +28,6 @@
#include <signal.h> #include <signal.h>
#include <uev/uev.h> #include <uev/uev.h>
#define SYNC_SHUTDOWN "/var/run/finit/.shutdown"
#define SETSIG(sa, sig, fun, flags) \ #define SETSIG(sa, sig, fun, flags) \
do { \ do { \
sa.sa_sigaction = fun; \ sa.sa_sigaction = fun; \