From f5b57183c852ec82d1f29c4ef2457e406a77ef4c Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Mon, 20 Jan 2020 17:49:28 +0100 Subject: [PATCH] daemon/main: set non-buffering stdout/stderr early Journald was missing some error messages when kresd failed to start. --- daemon/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/daemon/main.c b/daemon/main.c index 21c4a2d51..f329f4d5a 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -265,12 +265,6 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se return EXIT_FAILURE; } - if (setvbuf(stdout, NULL, _IONBF, 0) || setvbuf(stderr, NULL, _IONBF, 0)) { - kr_log_error("[system] failed to to set output buffering (ignored): %s\n", - strerror(errno)); - fflush(stderr); - } - /* Control sockets or TTY */ uv_pipe_t pipe; uv_pipe_init(loop, &pipe, 0); @@ -526,6 +520,12 @@ static void drop_capabilities(void) int main(int argc, char **argv) { + if (setvbuf(stdout, NULL, _IONBF, 0) || setvbuf(stderr, NULL, _IONBF, 0)) { + kr_log_error("[system] failed to to set output buffering (ignored): %s\n", + strerror(errno)); + fflush(stderr); + } + the_args = &the_args_value; args_init(the_args); int ret = parse_args(argc, argv, the_args); -- 2.47.2