From 2dedbc7211fb6b7f8b86148e6627054e781eaa87 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 21 Jun 2018 14:53:05 -0700 Subject: Drop return from SendExternalSignal SendExternalSignal is no longer called before CreateProcess, so it can enforce this simplified precondition. StartForwarding, and after Kernel.Start. PiperOrigin-RevId: 201591170 Change-Id: Ib7022ef7895612d7d82a00942ab59fa433c4d6e9 --- pkg/sentry/sighandling/sighandling.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pkg/sentry/sighandling') diff --git a/pkg/sentry/sighandling/sighandling.go b/pkg/sentry/sighandling/sighandling.go index ef6f7f617..25295440c 100644 --- a/pkg/sentry/sighandling/sighandling.go +++ b/pkg/sentry/sighandling/sighandling.go @@ -16,6 +16,7 @@ package sighandling import ( + "fmt" "os" "os/signal" "reflect" @@ -65,7 +66,9 @@ func forwardSignals(k *kernel.Kernel, sigchans []chan os.Signal, start, stop cha // Otherwise, it was a signal on channel N. Index 0 represents the stop // channel, so index N represents the channel for signal N. - if !started || !k.SendExternalSignal(&arch.SignalInfo{Signo: int32(index)}, "sentry") { + signal := linux.Signal(index) + + if !started { // Kernel is not ready to receive signals. // // Kill ourselves if this signal would have killed the @@ -78,11 +81,16 @@ func forwardSignals(k *kernel.Kernel, sigchans []chan os.Signal, start, stop cha // TODO: Convert Go's runtime.raise from // tkill to tgkill so PrepareForwarding doesn't need to // be called until after filter installation. - switch linux.Signal(index) { + switch signal { case linux.SIGHUP, linux.SIGINT, linux.SIGTERM: - dieFromSignal(linux.Signal(index)) + dieFromSignal(signal) + panic(fmt.Sprintf("Failed to die from signal %d", signal)) + default: + continue } } + + k.SendExternalSignal(&arch.SignalInfo{Signo: int32(signal)}, "sentry") } // Close all individual channels. -- cgit v1.2.3