From e8f5ec25798f0100eae12af4815b4c9a4132d7f4 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 3 Jun 2021 12:51:22 +0200 Subject: [PATCH] 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 --- src/exec.c | 33 +++++++++++++++++---------------- src/service.c | 2 +- src/sig.c | 5 ----- src/sig.h | 2 -- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/exec.c b/src/exec.c index e7ba451d..2d6a2e70 100644 --- a/src/exec.c +++ b/src/exec.c @@ -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; } /* diff --git a/src/service.c b/src/service.c index c86e33f2..8e94ce50 100644 --- a/src/service.c +++ b/src/service.c @@ -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); diff --git a/src/sig.c b/src/sig.c index 06fb3798..a7a87939 100644 --- a/src/sig.c +++ b/src/sig.c @@ -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 diff --git a/src/sig.h b/src/sig.h index a8820ab0..30a55b67 100644 --- a/src/sig.h +++ b/src/sig.h @@ -28,8 +28,6 @@ #include #include -#define SYNC_SHUTDOWN "/var/run/finit/.shutdown" - #define SETSIG(sa, sig, fun, flags) \ do { \ sa.sa_sigaction = fun; \