Skip to content

Honor an explicit stop signal on container stop#29052

Open
shuaiyuanxx wants to merge 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:stop-honor-signal
Open

Honor an explicit stop signal on container stop#29052
shuaiyuanxx wants to merge 1 commit into
podman-container-tools:mainfrom
shuaiyuanxx:stop-honor-signal

Conversation

@shuaiyuanxx

Copy link
Copy Markdown

What this PR does / why we need it:

podman ignored the signal for a graceful stop: the compat /stop endpoint dropped the signal query parameter, podman stop had no --signal flag, and the OCI runtime always used the container's configured StopSignal. Docker has supported
stop --signal (and the API signal parameter) since v1.42, so there was no way to stop a container with an override signal.

This threads an optional stop signal from the CLI (--signal/-s), the remote bindings, and the compat/libpod /stop endpoint down to the OCI runtime, which uses the override when given (0 = the configured StopSignal) and still escalates to SIGKILL after the timeout. Internal stop paths pass 0, so behavior is unchanged when no signal is requested.

How to verify it

    podman run -d --name s alpine sh -c 'trap "exit 42" USR1; while :; do sleep 0.1; done'
    podman stop --signal SIGUSR1 -t 20 s
    podman inspect s --format '{{.State.ExitCode}}'   # 42 = SIGUSR1 delivered (not the default)

New e2e test: podman stop container --signal.

Which issue(s) this PR fixes:

None

Checklist

  • Certify ... by signing all commits (git commit -s).
  • Referenced issues using Fixes: #issue (if applicable) — no related issue
  • Tests have been added/updated
  • Documentation has been updated (podman-stop.1.md.in)
  • All commits pass make validatepr — ran gofmt + go vet ./test/e2e + binary build + a runtime check; haven't run the full validatepr
  • Release note entered below

Does this PR introduce a user-facing change?

Added a `--signal`/`-s` option to `podman stop` and honored the `signal` query parameter on the stop API, so a container can be stopped with an explicit signal instead of its configured stop signal.

podman ignored the signal for a graceful stop: the compat /stop endpoint dropped
the "signal" query parameter, `podman stop` had no --signal flag, and the OCI
runtime always used the container's configured StopSignal. So there was no way
to stop a container with an override signal, even though Docker has supported
`stop --signal` (and the API "signal" parameter) since v1.42.

Thread an optional stop signal from the CLI (--signal/-s), the remote bindings,
and the compat/libpod /stop endpoint through to the OCI runtime. The runtime
uses the override when given (0 = the container's configured StopSignal) and
still escalates to SIGKILL after the timeout. Internal stop paths pass 0, so
behavior is unchanged when no signal is requested.

Signed-off-by: Shuai Yuan <shuaiyuanzju@gmail.com>
@github-actions github-actions Bot added the kind/api-change Change to remote API; merits scrutiny label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant