summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-12-11 16:11:53 -0800
committerShentubot <shentubot@google.com>2018-12-11 16:12:41 -0800
commit24c1158b9c21f7f8b7126e810d623a518422052e (patch)
tree960457b3b0476b1b9c61710f9526db953ba80f17 /runsc/boot
parent2b6df6a2049e839e39717f90c1760f3d410c98f1 (diff)
Add "trace signal" option
This option is effectively equivalent to -panic-signal, except that the sandbox does not die after logging the traceback. PiperOrigin-RevId: 225089593 Change-Id: Ifb1c411210110b6104613f404334bd02175e484e
Diffstat (limited to 'runsc/boot')
-rw-r--r--runsc/boot/config.go10
-rw-r--r--runsc/boot/loader.go6
2 files changed, 14 insertions, 2 deletions
diff --git a/runsc/boot/config.go b/runsc/boot/config.go
index 2d89ad87e..b98e38ae9 100644
--- a/runsc/boot/config.go
+++ b/runsc/boot/config.go
@@ -198,10 +198,17 @@ type Config struct {
// WatchdogAction sets what action the watchdog takes when triggered.
WatchdogAction watchdog.Action
- // PanicSignal register signal handling that panics. Usually set to
+ // PanicSignal registers signal handling that panics. Usually set to
// SIGUSR2(12) to troubleshoot hangs. -1 disables it.
+ //
+ // PanicSignal takes precedence over TraceSignal.
PanicSignal int
+ // TraceSignal registers signal handling that logs a traceback of all
+ // goroutines. Usually set to SIGUSR2(12) to troubleshoot hangs. -1
+ // disables it.
+ TraceSignal int
+
// TestOnlyAllowRunAsCurrentUserWithoutChroot should only be used in
// tests. It allows runsc to start the sandbox process as the current
// user, and without chrooting the sandbox process. This can be
@@ -228,5 +235,6 @@ func (c *Config) ToFlags() []string {
"--strace-log-size=" + strconv.Itoa(int(c.StraceLogSize)),
"--watchdog-action=" + c.WatchdogAction.String(),
"--panic-signal=" + strconv.Itoa(c.PanicSignal),
+ "--trace-signal=" + strconv.Itoa(c.TraceSignal),
}
}
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index 7cac346c9..a9c549790 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -324,10 +324,14 @@ func New(args Args) (*Loader, error) {
// Handle signals by forwarding them to the root container process
// (except for panic signal, which should cause a panic).
l.startSignalForwarding = sighandling.PrepareHandler(func(sig linux.Signal) {
- // Panic signal should cause a panic.
+ // Tracing signals should cause their respective actions.
if args.Conf.PanicSignal != -1 && sig == linux.Signal(args.Conf.PanicSignal) {
panic("Signal-induced panic")
}
+ if args.Conf.TraceSignal != -1 && sig == linux.Signal(args.Conf.TraceSignal) {
+ log.TracebackAll("Signal-induced traceback")
+ return
+ }
// Otherwise forward to root container.
deliveryMode := DeliverToProcess