Skip to content

Commit

Permalink
Merge pull request #33335 from cpuguy83/33334_check_unset_sig
Browse files Browse the repository at this point in the history
Check signal is unset before using user stopsignal
  • Loading branch information
thaJeztah committed Jun 1, 2017
2 parents 7ff2055 + 114652a commit 872e28b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion daemon/kill.go
Expand Up @@ -69,7 +69,7 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int)
return errNotRunning{container.ID}
}

if container.Config.StopSignal != "" {
if container.Config.StopSignal != "" && syscall.Signal(sig) != syscall.SIGKILL {
containerStopSignal, err := signal.ParseSignal(container.Config.StopSignal)
if err != nil {
return err
Expand Down
15 changes: 15 additions & 0 deletions integration-cli/docker_api_containers_test.go
Expand Up @@ -1933,3 +1933,18 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {
}
}
}

// Regression test for #33334
// Makes sure that when a container which has a custom stop signal + restart=always
// gets killed (with SIGKILL) by the kill API, that the restart policy is cancelled.
func (s *DockerSuite) TestContainerKillCustomStopSignal(c *check.C) {
id := strings.TrimSpace(runSleepingContainer(c, "--stop-signal=SIGTERM", "--restart=always"))
res, _, err := request.Post("/containers/" + id + "/kill")
c.Assert(err, checker.IsNil)
defer res.Body.Close()

b, err := ioutil.ReadAll(res.Body)
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent, check.Commentf(string(b)))
err = waitInspect(id, "{{.State.Running}} {{.State.Restarting}}", "false false", 30*time.Second)
c.Assert(err, checker.IsNil)
}

0 comments on commit 872e28b

Please sign in to comment.