Skip to content

Commit

Permalink
container: StopSignal(): return syscall.Signal
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed May 4, 2022
1 parent ea1eb44 commit 21df9a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,16 +511,16 @@ func (container *Container) IsDestinationMounted(destination string) bool {
}

// StopSignal returns the signal used to stop the container.
func (container *Container) StopSignal() int {
func (container *Container) StopSignal() syscall.Signal {
var stopSignal syscall.Signal
if container.Config.StopSignal != "" {
stopSignal, _ = signal.ParseSignal(container.Config.StopSignal)
}

if int(stopSignal) == 0 {
if stopSignal == 0 {
stopSignal, _ = signal.ParseSignal(defaultStopSignal)
}
return int(stopSignal)
return stopSignal
}

// StopTimeout returns the timeout (in seconds) used to stop the container.
Expand Down
2 changes: 1 addition & 1 deletion container/container_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestContainerStopSignal(t *testing.T) {
}

s := c.StopSignal()
if s != int(def) {
if s != def {
t.Fatalf("Expected %v, got %v", def, s)
}

Expand Down
3 changes: 1 addition & 2 deletions daemon/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package daemon // import "github.com/docker/docker/daemon"

import (
"context"
"syscall"
"time"

containertypes "github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -43,7 +42,7 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
}

var (
stopSignal = syscall.Signal(ctr.StopSignal())
stopSignal = ctr.StopSignal()
stopTimeout = ctr.StopTimeout()
)
if options.Signal != "" {
Expand Down

0 comments on commit 21df9a0

Please sign in to comment.