Fix wrong kill signal parsing
Signed-off-by: Antonio Murdaca <antonio.murdaca@gmail.com> Upstream-commit: 39eec4c25bce6291534f9524dc52de65787d5b6e Component: engine
This commit is contained in:
@ -58,3 +58,62 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
||||
c.Fatal("killed container is still running")
|
||||
}
|
||||
}
|
||||
|
||||
// regression test about correct signal parsing see #13665
|
||||
func (s *DockerSuite) TestKillWithSignal(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
cid := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cid), check.IsNil)
|
||||
|
||||
killCmd := exec.Command(dockerBinary, "kill", "-s", "SIGWINCH", cid)
|
||||
_, err = runCommand(killCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
running, err := inspectField(cid, "State.Running")
|
||||
if running != "true" {
|
||||
c.Fatal("Container should be in running state after SIGWINCH")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
cid := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cid), check.IsNil)
|
||||
|
||||
killCmd := exec.Command(dockerBinary, "kill", "-s", "0", cid)
|
||||
out, _, err = runCommandWithOutput(killCmd)
|
||||
c.Assert(err, check.NotNil)
|
||||
if !strings.ContainsAny(out, "Invalid signal: 0") {
|
||||
c.Fatal("Kill with an invalid signal didn't error out correctly")
|
||||
}
|
||||
|
||||
running, err := inspectField(cid, "State.Running")
|
||||
if running != "true" {
|
||||
c.Fatal("Container should be in running state after an invalid signal")
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
|
||||
out, _, err = runCommandWithOutput(runCmd)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
cid = strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cid), check.IsNil)
|
||||
|
||||
killCmd = exec.Command(dockerBinary, "kill", "-s", "SIG42", cid)
|
||||
out, _, err = runCommandWithOutput(killCmd)
|
||||
c.Assert(err, check.NotNil)
|
||||
if !strings.ContainsAny(out, "Invalid signal: SIG42") {
|
||||
c.Fatal("Kill with an invalid signal error out correctly")
|
||||
}
|
||||
|
||||
running, err = inspectField(cid, "State.Running")
|
||||
if running != "true" {
|
||||
c.Fatal("Container should be in running state after an invalid signal")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user