summaryrefslogtreecommitdiffhomepage
path: root/runsc/cmd
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-08-27 20:35:00 -0700
committerShentubot <shentubot@google.com>2018-08-27 20:36:10 -0700
commitae648bafda2d82a6641e4a28bed34dae40d426ec (patch)
tree5dc17ed7030585e6b140e1e743474e78e501a2d9 /runsc/cmd
parenta4529c1b5b485f6283367bfdc0e4228bbbd3e51f (diff)
Add command-line parameter to trigger panic on signal
This is to troubleshoot problems with a hung process that is not responding to 'runsc debug --stack' command. PiperOrigin-RevId: 210483513 Change-Id: I4377b210b4e51bc8a281ad34fd94f3df13d9187d
Diffstat (limited to 'runsc/cmd')
-rw-r--r--runsc/cmd/debug.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/runsc/cmd/debug.go b/runsc/cmd/debug.go
index 7952489de..b20987b2c 100644
--- a/runsc/cmd/debug.go
+++ b/runsc/cmd/debug.go
@@ -15,6 +15,8 @@
package cmd
import (
+ "syscall"
+
"context"
"flag"
"github.com/google/subcommands"
@@ -27,6 +29,7 @@ import (
type Debug struct {
pid int
stacks bool
+ signal int
}
// Name implements subcommands.Command.
@@ -48,6 +51,7 @@ func (*Debug) Usage() string {
func (d *Debug) SetFlags(f *flag.FlagSet) {
f.IntVar(&d.pid, "pid", 0, "sandbox process ID. Container ID is not necessary if this is set")
f.BoolVar(&d.stacks, "stacks", false, "if true, dumps all sandbox stacks to the log")
+ f.IntVar(&d.signal, "signal", -1, "sends signal to the sandbox")
}
// Execute implements subcommands.Command.Execute.
@@ -96,6 +100,12 @@ func (d *Debug) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
Fatalf("sandbox %q is not running", c.Sandbox.ID)
}
+ if d.signal > 0 {
+ log.Infof("Sending signal %d to process: %d", d.signal, c.Sandbox.Pid)
+ if err := syscall.Kill(c.Sandbox.Pid, syscall.Signal(d.signal)); err != nil {
+ Fatalf("failed to send signal %d to processs %d", d.signal, c.Sandbox.Pid)
+ }
+ }
if d.stacks {
log.Infof("Retrieving sandbox stacks")
stacks, err := c.Sandbox.Stacks()