]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: send READY=1 also when --lines=0 is given
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2025 12:01:59 +0000 (13:01 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2025 19:02:02 +0000 (20:02 +0100)
If --lines=0 is given, we'd skip the setup and not invoke sd_notify,
potentially blocking the caller. Change the condition for the callback
to also include that case. Since then the callback would always be
set, the 'if' statement is not necessary anymore.

src/journal/journalctl-show.c

index c48c2e47eb9a8fa41d435c19fec434c988f289b1..4ebedb092e8d1f26942c8662965a4fed870d11e2 100644 (file)
@@ -362,7 +362,9 @@ static int on_first_event(sd_event_source *s, void *userdata) {
                         return log_error_errno(r, "Failed to get cursor: %m");
         }
 
+        /* Setup and initial processing are done, we're ready to wait for more data. */
         (void) sd_notify(/* unset_environment= */ false, "READY=1");
+
         return 0;
 }
 
@@ -472,11 +474,9 @@ static int setup_event(Context *c, int fd) {
         else if (r < 0)
                 return log_error_errno(r, "Failed to add io event source for stdout: %m");
 
-        if (arg_lines != 0 || arg_since_set) {
-                r = sd_event_add_defer(e, NULL, on_first_event, c);
-                if (r < 0)
-                        return log_error_errno(r, "Failed to add defer event source: %m");
-        }
+        r = sd_event_add_defer(e, NULL, on_first_event, c);
+        if (r < 0)
+                return log_error_errno(r, "Failed to add defer event source: %m");
 
         c->event = TAKE_PTR(e);
         return 0;
@@ -583,6 +583,7 @@ int action_show(char **matches) {
                 return 0;
         }
 
+        /* Setup is done, we'll start processing data. */
         (void) sd_notify(/* unset_environment= */ false, "READY=1");
 
         r = show(&c);