]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: send READY=1
authorLennart Poettering <lennart@poettering.net>
Mon, 24 Mar 2025 10:53:32 +0000 (06:53 -0400)
committerLennart Poettering <lennart@poettering.net>
Tue, 13 May 2025 12:42:34 +0000 (14:42 +0200)
Allow callers to synchronize on the point in time where the journal file
watches are fully established, in --follow mode.

Tools can invoke journalctl using this, knowing that any log message
happening after the READY=1 is definitely going to be processed by the
journalctl invocation.

man/journalctl.xml
src/journal/journalctl-show.c

index b977c7521abebb4b06941f4d61a378902f0cb89e..7146c9400f850daea6570a201589957bc0434f5e 100644 (file)
         <term><option>-f</option></term>
         <term><option>--follow</option></term>
 
-        <listitem><para>Show only the most recent journal entries, and continuously print new entries as
-        they are appended to the journal.</para></listitem>
+        <listitem><para>Show only the most recent journal entries, and continuously print new entries as they
+        are appended to the journal, until Ctrl-C is hit (or the tool is otherwise terminated).</para>
+
+        <para><command>journalctl</command> will send an
+        <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+        <literal>READY=1</literal> message once it initialized and successfully established its watch on the
+        journal.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 620f2fc6a8de18057faa6989eea3b794028e5137..3519aa209ede044c6c5a935e94c128036526b3b8 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <unistd.h>
 
+#include "sd-daemon.h"
 #include "sd-event.h"
 
 #include "ansi-color.h"
@@ -329,6 +330,7 @@ static int on_first_event(sd_event_source *s, void *userdata) {
                         return log_error_errno(r, "Failed to get cursor: %m");
         }
 
+        (void) sd_notify(/* unset_environment= */ false, "READY=1");
         return 0;
 }
 
@@ -486,6 +488,8 @@ int action_show(char **matches) {
                 return sig;
         }
 
+        (void) sd_notify(/* unset_environment= */ false, "READY=1");
+
         r = show(&c);
         if (r < 0)
                 return r;