From 1eabab31aa40fb9a15841eed313fbb4e770dbdac Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 6 Mar 2018 12:54:16 -0500 Subject: [PATCH] Handle SIGPIPE in shims ref: https://github.com/moby/moby/issues/36464 Signed-off-by: Michael Crosby --- cmd/containerd-shim/main_unix.go | 1 + cmd/containerd-shim/shim_linux.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go index e682f0759..329fcbe99 100644 --- a/cmd/containerd-shim/main_unix.go +++ b/cmd/containerd-shim/main_unix.go @@ -208,6 +208,7 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal, server *ttrpc.S sv.Delete(context.Background(), &ptypes.Empty{}) close(done) }) + case unix.SIGPIPE: } } } diff --git a/cmd/containerd-shim/shim_linux.go b/cmd/containerd-shim/shim_linux.go index 294ec02ae..ff146fb2d 100644 --- a/cmd/containerd-shim/shim_linux.go +++ b/cmd/containerd-shim/shim_linux.go @@ -19,19 +19,19 @@ package main import ( "os" "os/signal" - "syscall" "github.com/containerd/containerd/reaper" runc "github.com/containerd/go-runc" "github.com/opencontainers/runc/libcontainer/system" "github.com/stevvooe/ttrpc" + "golang.org/x/sys/unix" ) // setupSignals creates a new signal handler for all signals and sets the shim as a // sub-reaper so that the container processes are reparented func setupSignals() (chan os.Signal, error) { signals := make(chan os.Signal, 32) - signal.Notify(signals, syscall.SIGTERM, syscall.SIGINT, syscall.SIGCHLD) + signal.Notify(signals, unix.SIGTERM, unix.SIGINT, unix.SIGCHLD, unix.SIGPIPE) // make sure runc is setup to use the monitor // for waiting on processes runc.Monitor = reaper.Default