From b3c478f19eed15d63bc160cb0737e3ce65687253 Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 24 Jul 2023 11:54:49 +0200 Subject: [PATCH] init: Make the log stream line-buffered Looks like log output stopped showing after buffering was implemented, since the log was not flushed properly. --- apps/init.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/init.cpp b/apps/init.cpp index 47f4c4c9..6ec99984 100644 --- a/apps/init.cpp +++ b/apps/init.cpp @@ -328,13 +328,15 @@ int main() umask(022); - g_init_log = fopen("/dev/uart0", "w+"); + g_init_log = fopen("/dev/uart0", "w"); + check(g_init_log); + setlinebuf(g_init_log); fcntl(fileno(g_init_log), F_SETFD, FD_CLOEXEC); set_hostname(); - if (signal(SIGTERM, sigterm_handler) == SIG_ERR) do_log("[init] failed to register handler for SIGTERM"); - if (signal(SIGQUIT, sigquit_handler) == SIG_ERR) do_log("[init] failed to register handler for SIGQUIT"); + if (signal(SIGTERM, sigterm_handler) == SIG_ERR) do_log("[init] failed to register handler for SIGTERM\n"); + if (signal(SIGQUIT, sigquit_handler) == SIG_ERR) do_log("[init] failed to register handler for SIGQUIT\n"); start_services();