summaryrefslogtreecommitdiffstats
path: root/src/busctl
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2024-08-07 21:41:20 +0200
committerLuca Boccassi <bluca@debian.org>2024-08-08 10:18:41 +0200
commit989e843e7543b21b91de4368da44692d674722a5 (patch)
treefc4919ae168d3768b6359cb395bb5ebc66588fef /src/busctl
parentmeson: enable -Wunterminated-string-initialization (diff)
downloadsystemd-989e843e7543b21b91de4368da44692d674722a5.tar.xz
systemd-989e843e7543b21b91de4368da44692d674722a5.zip
busctl: add support for --timeout to monitor verb
Useful in scripts when you want to exit successfully after a certain time
Diffstat (limited to 'src/busctl')
-rw-r--r--src/busctl/busctl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index 4a5fac7606..31104f36c5 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -1373,7 +1373,12 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
if (r > 0)
continue;
- r = sd_bus_wait(bus, UINT64_MAX);
+ r = sd_bus_wait(bus, arg_timeout > 0 ? arg_timeout : UINT64_MAX);
+ if (r == 0 && arg_timeout > 0) {
+ if (!arg_quiet && arg_json_format_flags == SD_JSON_FORMAT_OFF)
+ log_info("Timed out waiting for messages, exiting.");
+ return 0;
+ }
if (r < 0)
return log_error_errno(r, "Failed to wait for bus: %m");
}