mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
compat kill: only wait for 0 signal and sigkill
Docker does not wait unconditionally. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/containers/podman/v2/libpod"
|
"github.com/containers/podman/v2/libpod"
|
||||||
"github.com/containers/podman/v2/libpod/define"
|
"github.com/containers/podman/v2/libpod/define"
|
||||||
@ -169,16 +170,16 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = con.Kill(uint(sig))
|
signal := uint(sig)
|
||||||
|
|
||||||
|
err = con.Kill(signal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "unable to kill Container %s", name))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "unable to kill Container %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.IsLibpodRequest(r) {
|
// Docker waits for the container to stop if the signal is 0 or
|
||||||
// the kill behavior for docker differs from podman in that they appear to wait
|
// SIGKILL.
|
||||||
// for the Container to croak so the exit code is accurate immediately after the
|
if !utils.IsLibpodRequest(r) && (signal == 0 || syscall.Signal(signal) == syscall.SIGKILL) {
|
||||||
// kill is sent. libpod does not. but we can add a wait here only for the docker
|
|
||||||
// side of things and mimic that behavior
|
|
||||||
if _, err = con.Wait(); err != nil {
|
if _, err = con.Wait(); err != nil {
|
||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to wait for Container %s", con.ID()))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to wait for Container %s", con.ID()))
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user