journalctl: optionally delay --follow exit for a journal synchronization

Let's optionally issue a Varlink Synchronize() call in --follow mode
when asked to terminate. This is useful so that the tool can be called
and it is guaranteed it processed all messages generated before the
request to exit before it exits.

We want this in "systemd-run -v" in particular, so that we can be sure
we are not missing any log output from the invoked service before it
exits
This commit is contained in:
Lennart Poettering
2025-05-13 15:39:57 +02:00
parent 5be930db9f
commit d2f45c7681
7 changed files with 118 additions and 19 deletions
+2 -1
View File
@@ -127,7 +127,8 @@ int journal_fork(RuntimeScope scope, const char * const *units, PidRef *ret_pidr
"-q",
"--follow",
"--no-pager",
"--lines=1");
"--lines=1",
"--synchronize-on-exit=yes");
if (!argv)
return log_oom_debug();