mirror of
https://github.com/systemd/systemd.git
synced 2026-08-11 01:25:28 +00:00
run: honor --no-block for trigger units
Reproducer:
unit=run-nb-trigger-$(date +%s)
systemd-run --no-block --collect --unit="$unit" \
--socket-property=ListenStream=/proc/systemd-run-repro/socket \
/usr/bin/true
echo $?
Before, systemd-run still waited for the trigger unit job and
propagated the socket start failure. With --no-block it should only
verify and enqueue the request, as the service path already does.
Follow-up for 3d161f991e
This commit is contained in:
@@ -2808,9 +2808,11 @@ static int start_transient_trigger(sd_bus *bus, const char *suffix) {
|
||||
assert(bus);
|
||||
assert(suffix);
|
||||
|
||||
r = bus_wait_for_jobs_new(bus, &w);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not watch jobs: %m");
|
||||
if (!arg_no_block) {
|
||||
r = bus_wait_for_jobs_new(bus, &w);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not watch jobs: %m");
|
||||
}
|
||||
|
||||
if (arg_unit) {
|
||||
switch (unit_name_to_type(arg_unit)) {
|
||||
@@ -2875,10 +2877,12 @@ static int start_transient_trigger(sd_bus *bus, const char *suffix) {
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR,
|
||||
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (w) {
|
||||
r = bus_wait_for_jobs_one(w, object, arg_quiet ? 0 : BUS_WAIT_JOBS_LOG_ERROR,
|
||||
arg_runtime_scope == RUNTIME_SCOPE_USER ? STRV_MAKE_CONST("--user") : NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!arg_quiet) {
|
||||
log_info("Running %s as unit: %s", suffix + 1, trigger);
|
||||
|
||||
@@ -205,6 +205,13 @@ grep -q "^SocketMode=0644$" "/run/systemd/transient/$UNIT.socket"
|
||||
grep -qE "^ExecStart=.*true.*$" "/run/systemd/transient/$UNIT.service"
|
||||
systemctl stop "$UNIT.socket" "$UNIT.service" || :
|
||||
|
||||
UNIT="socket-no-block-$RANDOM"
|
||||
systemd-run --no-block --collect \
|
||||
--unit="$UNIT" \
|
||||
--socket-property=ListenStream=/proc/systemd-run-repro/socket \
|
||||
true
|
||||
systemctl stop "$UNIT.socket" "$UNIT.service" || :
|
||||
|
||||
: "Job mode"
|
||||
systemd-run --job-mode=help
|
||||
(! systemd-run --job-mode=foo --scope true)
|
||||
|
||||
Reference in New Issue
Block a user