From cd3b13d3b207f7aff2755cc1f5745f7e32de24d6 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 25 May 2019 17:10:34 +1000 Subject: [PATCH] Fix waiting for console input. --- src/dinit.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dinit.cc b/src/dinit.cc index 3458118..40d1fe3 100644 --- a/src/dinit.cc +++ b/src/dinit.cc @@ -149,6 +149,7 @@ namespace { } }; + // Watch for console input and set a flag when it is available. class console_input_watcher : public eventloop_t::fd_watcher_impl { using rearm = dasynq::rearm; @@ -156,8 +157,8 @@ namespace { public: rearm fd_event(eventloop_t &loop, int fd, int flags) noexcept { - control_socket_cb(&loop, fd); // DAV - return rearm::REARM; + console_input_ready = true; + return rearm::DISARM; } }; @@ -633,6 +634,7 @@ static void confirm_restart_boot() noexcept // We either have input, or shutdown type has been set, or both. if (console_input_ready) { + console_input_ready = false; char buf[1]; int r = read(STDIN_FILENO, buf, 1); // read a single character, to make sure we wait for input if (r == 1) { @@ -659,7 +661,6 @@ static void confirm_restart_boot() noexcept } } tcflush(STDIN_FILENO, TCIFLUSH); // discard the rest of input - console_input_ready = false; } term_attr.c_lflag |= ICANON; -- 2.25.1