From: Tomas Krizek Date: Mon, 20 Jan 2020 16:49:28 +0000 (+0100) Subject: daemon/main: set non-buffering stdout/stderr early X-Git-Tag: v5.0.0~1^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5b57183c852ec82d1f29c4ef2457e406a77ef4c;p=thirdparty%2Fknot-resolver.git daemon/main: set non-buffering stdout/stderr early Journald was missing some error messages when kresd failed to start. --- 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);