busctl: handle --limit-messages option under the wait verb

Main focus was to not introduce breaking change or duplicated argument.
The `--limit-messages=` option that is used under the `monitor` verb is
reused here. However, both `wait` and `monitor` have contradicting
default behaviors, so it's not the cleanest thing to do.

There was some post-commit discussion about the API in #33961, but the
final name adopted in #34928 wasn't that flexible either to fit nicely
here in the `wait` verbe.

Additionally, there wasn't consideration in #34555 for having uniform
behavrious, so we ended with `wait` verb and `--limit-messages=` option,
rather than `receive` verb with default of continuously receving signals
withtout exit so `--limit-messages=` make more sence and be expectable.
This commit is contained in:
zefr0x
2026-01-19 22:41:33 +09:00
committed by Yu Watanabe
parent 30f3a7ad51
commit 985a6fa44b
3 changed files with 60 additions and 10 deletions
+19 -2
View File
@@ -57,10 +57,27 @@ busctl emit --auto-start=no --destination=systemd-logind.service \
/org/freedesktop/login1 org.freedesktop.login1.Manager \
PrepareForShutdown b false
signal_emit_command() {
echo "for i in \$(seq 1 ${1:?}); do busctl emit /test org.freedesktop.fake1 TestSignal s success; done"
}
systemd-run --quiet --service-type=notify --unit=test-busctl-wait --pty \
-p Environment=SYSTEMD_LOG_LEVEL=debug \
-p ExecStartPost="busctl emit /test org.freedesktop.fake1 TestSignal s success" \
busctl --timeout=30 wait /test org.freedesktop.fake1 TestSignal | grep -F 's "success"' >/dev/null
-p ExecStartPost="sh -c '$(signal_emit_command 1)'" \
busctl --timeout=30 wait /test org.freedesktop.fake1 TestSignal |
grep -Fc 's "success"' | xargs test 1 -eq
systemd-run --quiet --service-type=notify --unit=test-busctl-wait-limited --pty \
-p Environment=SYSTEMD_LOG_LEVEL=debug \
-p ExecStartPost="sh -c '$(signal_emit_command 5)'" \
busctl --timeout=30 --limit-messages=3 wait /test org.freedesktop.fake1 TestSignal |
grep -Fc 's "success"' | xargs test 3 -eq
systemd-run --quiet --service-type=notify --unit=test-busctl-wait-unlimited --pty \
-p Environment=SYSTEMD_LOG_LEVEL=debug \
-p ExecStartPost="sh -c '$(signal_emit_command 2)'" \
busctl --timeout=3 --limit-messages=infinity wait /test org.freedesktop.fake1 TestSignal |
grep -Fc 's "success"' | xargs test 2 -eq
busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager \
Version