From 21df9a04e011dd1e13ae327a0bbe3fc307c86766 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 2 May 2022 01:16:56 +0200 Subject: [PATCH] container: StopSignal(): return syscall.Signal Signed-off-by: Sebastiaan van Stijn --- container/container.go | 6 +++--- container/container_unit_test.go | 2 +- daemon/stop.go | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/container/container.go b/container/container.go index 9edbcbb0a7..5ca14523fd 100644 --- a/container/container.go +++ b/container/container.go @@ -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. diff --git a/container/container_unit_test.go b/container/container_unit_test.go index 030583039d..3e4c6e4fa5 100644 --- a/container/container_unit_test.go +++ b/container/container_unit_test.go @@ -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) } diff --git a/daemon/stop.go b/daemon/stop.go index 517b7953af..5a659c1cc8 100644 --- a/daemon/stop.go +++ b/daemon/stop.go @@ -2,7 +2,6 @@ package daemon // import "github.com/docker/docker/daemon" import ( "context" - "syscall" "time" containertypes "github.com/docker/docker/api/types/container" @@ -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 != "" {