From 6bf8670b694278e5e53655ad40605d099f7ae02b Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Fri, 9 Sep 2022 13:29:40 +0200 Subject: stop: fix error handling Fix the error handling in the fallback logic of `stop` when Podman resorts to killing a container; the error message wrapped the wrong error. [NO NEW TESTS NEEDED] as it is a rare flake in the tests and I do not know how to reliably reproduce it. Fixes: #15661 Signed-off-by: Valentin Rothberg --- libpod/oci_conmon_common.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index 87f0aa4ad..0c61de360 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -429,13 +429,11 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool) } } - if err := r.KillContainer(ctr, 9, all); err != nil { + if err := r.KillContainer(ctr, uint(unix.SIGKILL), all); err != nil { // Again, check if the container is gone. If it is, exit cleanly. - err := unix.Kill(ctr.state.PID, 0) - if err == unix.ESRCH { + if aliveErr := unix.Kill(ctr.state.PID, 0); errors.Is(aliveErr, unix.ESRCH) { return nil } - return fmt.Errorf("error sending SIGKILL to container %s: %w", ctr.ID(), err) } -- cgit v1.2.3-54-g00ecf