diff --git a/man/systemd-run.xml b/man/systemd-run.xml index d0eec8cf0d..e9c6384363 100644 --- a/man/systemd-run.xml +++ b/man/systemd-run.xml @@ -216,7 +216,9 @@ After the service process has terminated, keep the service around until it is explicitly stopped. This is useful to collect runtime information about the service after it finished running. Also see RemainAfterExit= in - systemd.service5. + systemd.service5. This + option may not be combined with , , , + , or . @@ -529,8 +531,9 @@ completed). On exit, terse information about the unit's runtime is shown, including total runtime (as well as CPU, memory, IO, and IP accounting data, if the corresponding cgroup accounting settings are enabled) and the exit code and status of the main process. This output may be suppressed with . - This option may not be combined with , or the various - path, socket, or timer options. + This option may not be combined with , + , or the various path, socket, or timer + options. diff --git a/src/run/run.c b/src/run/run.c index dd5a207455..85256a2b1b 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -717,6 +717,10 @@ static int parse_argv(int argc, char *argv[]) { if (arg_no_block) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--pty/--pty-late/--pipe is not compatible with --no-block."); + + if (arg_remain_after_exit) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "--pty/--pty-late/--pipe is not compatible with --remain-after-exit."); } if (arg_stdio == ARG_STDIO_PTY && arg_pty_late && streq_ptr(arg_service_type, "oneshot")) @@ -761,6 +765,10 @@ static int parse_argv(int argc, char *argv[]) { if (arg_scope) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--wait may not be combined with --scope."); + + if (arg_remain_after_exit) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "--wait may not be combined with --remain-after-exit."); } if (arg_scope && arg_root_directory) diff --git a/test/units/TEST-74-AUX-UTILS.run.sh b/test/units/TEST-74-AUX-UTILS.run.sh index c85117e135..1c0efdf08f 100755 --- a/test/units/TEST-74-AUX-UTILS.run.sh +++ b/test/units/TEST-74-AUX-UTILS.run.sh @@ -72,6 +72,8 @@ systemctl cat "$UNIT" grep -q "^Type=oneshot" "/run/systemd/transient/$UNIT.service" systemctl stop "$UNIT" (! systemctl cat "$UNIT") +(! systemd-run --wait --remain-after-exit true) +(! systemd-run --pipe --remain-after-exit true) : "Transient service (user daemon)" systemd-run --wait --pipe --user --machine=testuser@ \