diff options
author | Cory Snider <csnider@mirantis.com> | 2023-04-11 20:18:25 -0400 |
---|---|---|
committer | Cory Snider <csnider@mirantis.com> | 2023-04-25 17:50:12 -0400 |
commit | 16d5d4b6e1e85b0e82059be6914a12374c3fc81c (patch) | |
tree | 92e8b13963d73d468416e7eab2cb34d2d52d2a1f /cmd | |
parent | 0970cb054c9606c727dda5240750482d0f40f729 (diff) | |
download | docker-16d5d4b6e1e85b0e82059be6914a12374c3fc81c.tar.gz |
cmd/dockerd: ignore SIGPIPE using signal.Ignore
The fix to ignore SIGPIPE signals was originally added in the Go 1.4
era. signal.Ignore was first added in Go 1.5.
Signed-off-by: Cory Snider <csnider@mirantis.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dockerd/docker.go | 7 | ||||
-rw-r--r-- | cmd/dockerd/trap/trap.go | 11 |
2 files changed, 9 insertions, 9 deletions
diff --git a/cmd/dockerd/docker.go b/cmd/dockerd/docker.go index da11a0cfdd..5b4d5f5c0f 100644 --- a/cmd/dockerd/docker.go +++ b/cmd/dockerd/docker.go @@ -3,6 +3,8 @@ package main import ( "fmt" "os" + "os/signal" + "syscall" "github.com/docker/docker/daemon/config" "github.com/docker/docker/dockerversion" @@ -77,6 +79,11 @@ func main() { return } + // Ignore SIGPIPE events. These are generated by systemd when journald is restarted while + // the docker daemon is not restarted and also running under systemd. + // Fixes https://github.com/docker/docker/issues/19728 + signal.Ignore(syscall.SIGPIPE) + // initial log formatting; this setting is updated after the daemon configuration is loaded. logrus.SetFormatter(&logrus.TextFormatter{ TimestampFormat: jsonmessage.RFC3339NanoFixed, diff --git a/cmd/dockerd/trap/trap.go b/cmd/dockerd/trap/trap.go index 1e88e66302..62cbfaf1ca 100644 --- a/cmd/dockerd/trap/trap.go +++ b/cmd/dockerd/trap/trap.go @@ -15,22 +15,15 @@ import ( // - If SIGINT or SIGTERM are received, `cleanup` is called, then the process is terminated. // - If SIGINT or SIGTERM are received 3 times before cleanup is complete, then cleanup is // skipped and the process is terminated immediately (allows force quit of stuck daemon) -// - Ignore SIGPIPE events. These are generated by systemd when journald is restarted while -// the docker daemon is not restarted and also running under systemd. -// Fixes https://github.com/docker/docker/issues/19728 func Trap(cleanup func(), logger interface { Info(args ...interface{}) }) { c := make(chan os.Signal, 1) - // we will handle INT, TERM, SIGPIPE here - signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGPIPE) + // we will handle INT, TERM here + signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { interruptCount := uint32(0) for sig := range c { - if sig == syscall.SIGPIPE { - continue - } - go func(sig os.Signal) { logger.Info(fmt.Sprintf("Processing signal '%v'", sig)) switch sig { |