summaryrefslogtreecommitdiff
path: root/mu/mu-cmd-server.cc
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2022-02-03 22:58:53 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2022-02-03 23:04:18 +0200
commitb6d7d142f666d36bb876b8bf035a07ad89bf6bfd (patch)
tree1e600386266da72fc24667472989eaaf6de8999a /mu/mu-cmd-server.cc
parent05393ba7977efe993b014d3932794485fc443dca (diff)
server: support flushing the output
So we can get some progress output
Diffstat (limited to 'mu/mu-cmd-server.cc')
-rw-r--r--mu/mu-cmd-server.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/mu/mu-cmd-server.cc b/mu/mu-cmd-server.cc
index bb39dad..cfa326c 100644
--- a/mu/mu-cmd-server.cc
+++ b/mu/mu-cmd-server.cc
@@ -82,7 +82,7 @@ cookie(size_t n)
}
static void
-output_sexp_stdout(Sexp&& sexp)
+output_sexp_stdout(Sexp&& sexp, bool flush = false)
{
const auto str{sexp.to_sexp_string()};
cookie(str.size() + 1);
@@ -90,6 +90,9 @@ output_sexp_stdout(Sexp&& sexp)
g_critical("failed to write output '%s'", str.c_str());
::raise(SIGTERM); /* terminate ourselves */
}
+
+ if (flush)
+ ::fflush(::stdout);
}
static void
@@ -100,7 +103,7 @@ report_error(const Mu::Error& err) noexcept
e.add_prop(":error", Sexp::make_number(static_cast<size_t>(err.code())));
e.add_prop(":message", Sexp::make_string(err.what()));
- output_sexp_stdout(Sexp::make_list(std::move(e)));
+ output_sexp_stdout(Sexp::make_list(std::move(e)), true /*flush*/);
}
MuError