1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-26 08:55:40 +03:00
This commit is contained in:
Lennart Poettering 2024-10-25 11:57:53 -07:00 committed by GitHub
commit a32f689398
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 53 deletions

View File

@ -402,33 +402,20 @@
<term><option>--timeout=<replaceable>SECS</replaceable></option></term>
<listitem>
<para>When used with the <command>call</command> command, specifies the maximum time to wait for
method call completion. When used with the <command>monitor</command> command, since version v257,
specifies the maximum time to wait for messages before automatically exiting. If no time unit is
specified, assumes seconds. The usual other units are understood, too (ms, us, s, min, h, d, w,
month, y). Note that this timeout does not apply if <option>--expect-reply=no</option> is used,
when combined with the <command>call</command> command, as the tool does not wait for any reply
message then. When not specified or when set to 0, the default of <literal>25s</literal> is
assumed for the <command>call</command> command, and it is disabled for the
<command>monitor</command> command.</para>
<para>When used with the <command>call</command> command,
specifies the maximum time to wait for method call
completion. If no time unit is specified, assumes
seconds. The usual other units are understood, too (ms, us,
s, min, h, d, w, month, y). Note that this timeout does not
apply if <option>--expect-reply=no</option> is used, as the
tool does not wait for any reply message then. When not
specified or when set to 0, the default of
<literal>25s</literal> is assumed.</para>
<xi:include href="version-info.xml" xpointer="v218"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--num-matches=<replaceable>NUMBER</replaceable></option></term>
<listitem>
<para>When used with the <command>monitor</command> command, if enabled will make
<command>busctl</command> exit when the specified number of messages have been received and
printed. This is useful in combination with <option>--match=</option>, to wait for the specified
number of occurrences of specific D-Bus messages.</para>
<xi:include href="version-info.xml" xpointer="v257"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--augment-creds=<replaceable>BOOL</replaceable></option></term>

View File

@ -89,7 +89,7 @@ _busctl() {
--allow-interactive-authorization=no --augment-creds=no
--watch-bind=yes -j -l --full --xml-interface'
[ARG]='--address -H --host -M --machine --match --timeout --size --json
--destination --num-matches'
--destination'
)
if __contains_word "--user" ${COMP_WORDS[*]}; then

View File

@ -308,7 +308,6 @@ _arguments \
'--expect-reply=[Expect a method call reply]:boolean:(1 0)' \
'--auto-start=[Auto-start destination service]:boolean:(1 0)' \
'--allow-interactive-authorization=[Allow interactive authorization for operation]:boolean:(1 0)' \
'--timeout=[Maximum time to wait for method call completion and monitoring]:timeout (seconds)' \
'--timeout=[Maximum time to wait for method call completion]:timeout (seconds)' \
'--augment-creds=[Extend credential data with data read from /proc/$PID]:boolean:(1 0)' \
'--num-matches=[Exit after receiving a number of matches while monitoring]:integer' \
'*::busctl command:_busctl_commands'

View File

@ -65,7 +65,6 @@ static bool arg_augment_creds = true;
static bool arg_watch_bind = false;
static usec_t arg_timeout = 0;
static const char *arg_destination = NULL;
static uint64_t arg_num_matches = UINT64_MAX;
STATIC_DESTRUCTOR_REGISTER(arg_matches, strv_freep);
@ -1364,12 +1363,6 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
dump(m, stdout);
fflush(stdout);
if (arg_num_matches != UINT64_MAX && --arg_num_matches == 0) {
if (!arg_quiet && arg_json_format_flags == SD_JSON_FORMAT_OFF)
log_info("Received requested number of matching messages, exiting.");
return 0;
}
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected") > 0) {
if (!arg_quiet && arg_json_format_flags == SD_JSON_FORMAT_OFF)
log_info("Connection terminated, exiting.");
@ -1382,12 +1375,7 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
if (r > 0)
continue;
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;
}
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0)
return log_error_errno(r, "Failed to wait for bus: %m");
}
@ -2500,8 +2488,6 @@ static int help(void) {
" --watch-bind=BOOL Wait for bus AF_UNIX socket to be bound in the file\n"
" system\n"
" --destination=SERVICE Destination service of a signal\n"
" --num-matches=NUMBER Exit after receiving a number of matches while\n"
" monitoring\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
ansi_highlight(),
@ -2541,7 +2527,6 @@ static int parse_argv(int argc, char *argv[]) {
ARG_WATCH_BIND,
ARG_JSON,
ARG_DESTINATION,
ARG_NUM_MATCHES,
};
static const struct option options[] = {
@ -2574,7 +2559,6 @@ static int parse_argv(int argc, char *argv[]) {
{ "watch-bind", required_argument, NULL, ARG_WATCH_BIND },
{ "json", required_argument, NULL, ARG_JSON },
{ "destination", required_argument, NULL, ARG_DESTINATION },
{ "num-matches", required_argument, NULL, ARG_NUM_MATCHES },
{},
};
@ -2743,15 +2727,6 @@ static int parse_argv(int argc, char *argv[]) {
arg_destination = optarg;
break;
case ARG_NUM_MATCHES:
r = safe_atou64(optarg, &arg_num_matches);
if (r < 0)
return log_error_errno(r, "Failed to parse --num-matches= parameter '%s': %m", optarg);
if (arg_num_matches == 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--num-matches= parameter cannot be 0");
break;
case '?':
return -EINVAL;

View File

@ -116,5 +116,3 @@ busctl get-property -j \
# Invalid argument
(! busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager \
KExecWatchdogUSec t "foo")
busctl --quiet --timeout 1 --num-matches 1 --match "interface=org.freedesktop.systemd1.Manager" monitor >/dev/null