From f9afde9b888dcc67786ea49e244c3a6dc644792a Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Fri, 29 Apr 2022 11:43:42 -0700 Subject: [PATCH] Exempt SIGPIPE from sentry signal forwarding. The sentry may get SIGPIPE from writing to readerless pipes or shutdown sockets; in these cases, it's incorrect to forward the SIGPIPE to app PID 1. (It would be correct to send SIGPIPE to the app thread performing the write instead, but we can't do so with signal forwarding since (1) we can't identify the correct app thread to signal and (2) Go signal handling with os/signal is async - the sentry thread that received SIGPIPE continued execution after doing so, so the app thread may already be running. Having the sentry send SIGPIPE independently of the host is gvisor.dev/issue/161.) Updates #7293 PiperOrigin-RevId: 445469810 --- pkg/sighandling/sighandling.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sighandling/sighandling.go b/pkg/sighandling/sighandling.go index bdaf8af29..ba26d63fc 100644 --- a/pkg/sighandling/sighandling.go +++ b/pkg/sighandling/sighandling.go @@ -90,6 +90,10 @@ func StartSignalForwarding(handler func(linux.Signal)) func() { if sig == int(linux.SIGURG) { continue } + // SIGPIPE is received when sending to disconnected host pipes/sockets. + if sig == int(linux.SIGPIPE) { + continue + } signal.Notify(sigchan, unix.Signal(sig)) } // Start up our listener.