From 0ed07360cd7e229cb458580de1f349d5d9f3568b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 23 Apr 2021 10:34:00 +0200 Subject: json: Flush standard file descriptors before calling hooks This ensures messages are displayed in the correct order. --- apt-private/private-json-hooks.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'apt-private') diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc index 7991a7d77..6bf70b1c6 100644 --- a/apt-private/private-json-hooks.cc +++ b/apt-private/private-json-hooks.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -335,6 +336,13 @@ bool RunJsonHook(std::string const &option, std::string const &method, const cha return true; Opts = Opts->Child; + // Flush output before calling hooks + std::clog.flush(); + std::cerr.flush(); + std::cout.flush(); + c2out.flush(); + c1out.flush(); + sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN); sighandler_t old_sigint = signal(SIGINT, SIG_IGN); sighandler_t old_sigquit = signal(SIGQUIT, SIG_IGN); -- cgit v1.2.3-70-g09d2