summaryrefslogtreecommitdiff
path: root/apt-private/private-json-hooks.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2021-04-23 10:34:00 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2021-04-23 12:25:40 +0200
commit0ed07360cd7e229cb458580de1f349d5d9f3568b (patch)
tree69b2f95418a714d90ea8e8dc946df59b0e020450 /apt-private/private-json-hooks.cc
parentb5211b9b213273c642a790ae3c3f3bbe1a4cf51e (diff)
json: Flush standard file descriptors before calling hooks
This ensures messages are displayed in the correct order.
Diffstat (limited to 'apt-private/private-json-hooks.cc')
-rw-r--r--apt-private/private-json-hooks.cc8
1 files changed, 8 insertions, 0 deletions
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 <apt-pkg/macros.h>
#include <apt-pkg/strutl.h>
#include <apt-private/private-json-hooks.h>
+#include <apt-private/private-output.h>
#include <iomanip>
#include <ostream>
@@ -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);