jiri/runutil: use SIGQUIT on timeout in order to get stack dumps
Change-Id: I39a186419c3aad53ba6e86ae9e945d569668edd5
diff --git a/runutil/executor.go b/runutil/executor.go
index b7c4c36..44a18e9 100644
--- a/runutil/executor.go
+++ b/runutil/executor.go
@@ -154,7 +154,7 @@
// Kill this process group explicitly when receiving SIGTERM
// or SIGINT signals.
sigchan := make(chan os.Signal, 1)
- signal.Notify(sigchan, syscall.SIGTERM, syscall.SIGINT)
+ signal.Notify(sigchan, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT)
go func() {
<-sigchan
e.terminateProcessGroup(command)
@@ -193,12 +193,14 @@
}
}
-// terminateProcessGroup sends SIGTERM followed by SIGKILL to the
+// terminateProcessGroup sends SIGQUIT followed by SIGKILL to the
// process group (the negative value of the process's pid).
func (e *executor) terminateProcessGroup(command *exec.Cmd) {
pid := -command.Process.Pid
- if err := syscall.Kill(pid, syscall.SIGTERM); err != nil {
- fmt.Fprintf(e.opts.Stderr, "Kill(%v, %v) failed: %v\n", pid, syscall.SIGTERM, err)
+ // Use SIGQUIT in order to get a stack dump of potentially hanging
+ // commands.
+ if err := syscall.Kill(pid, syscall.SIGQUIT); err != nil {
+ fmt.Fprintf(e.opts.Stderr, "Kill(%v, %v) failed: %v\n", pid, syscall.SIGQUIT, err)
}
fmt.Fprintf(e.opts.Stderr, "Waiting for command to exit: %q\n", command.Args)
// Give the process some time to shut down cleanly.