From 99a7386a9e00a9b79e1f220efb2ebdf06ca21f44 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 17 Mar 2025 00:26:45 +0100 Subject: [PATCH 1/3] run: "trigger" consists of more than timer units --- src/run/run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run/run.c b/src/run/run.c index acec362a40..7d66590b34 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -764,7 +764,7 @@ static int parse_argv(int argc, char *argv[]) { if (arg_stdio != ARG_STDIO_NONE) { if (with_trigger || arg_scope) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "--pty/--pty-late/--pipe is not compatible in timer or --scope mode."); + "--pty/--pty-late/--pipe is not compatible in trigger (path/socket/timer units) or --scope mode."); if (arg_transport == BUS_TRANSPORT_REMOTE) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), From 647ff4b65ec078ec384957268d7919be828fab62 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 17 Mar 2025 00:11:12 +0100 Subject: [PATCH 2/3] run: void'ify sd_event_exit() call --- src/run/run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run/run.c b/src/run/run.c index 7d66590b34..182925aff0 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -1679,7 +1679,7 @@ static int run_context_check_started(RunContext *c) { /* Setup ptyfwd now if --pty-late is specified. */ r = run_context_setup_ptyfwd(c); if (r < 0) { - sd_event_exit(c->event, EXIT_FAILURE); + (void) sd_event_exit(c->event, EXIT_FAILURE); return r; } From 2fb10b3cfbfd4e9cc8de5f8dc90a6e7a83470561 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 17 Mar 2025 00:21:46 +0100 Subject: [PATCH 3/3] run: refuse --pty-late for Type=oneshot services Such combination makes no sense, as by the time the start job of the oneshot service finishes the main process has already exited. Addresses https://github.com/systemd/systemd/pull/36691#discussion_r1988116881 --- src/run/run.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/run/run.c b/src/run/run.c index 182925aff0..523993cffd 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -775,6 +775,10 @@ static int parse_argv(int argc, char *argv[]) { "--pty/--pty-late/--pipe is not compatible with --no-block."); } + if (arg_stdio == ARG_STDIO_PTY && arg_pty_late && streq_ptr(arg_service_type, "oneshot")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "--pty-late is not compatible with --service-type=oneshot."); + if (arg_scope && with_trigger) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Path, socket or timer options are not supported in --scope mode.");