diff --git a/edit/editor.go b/edit/editor.go index a1861df0..f0214f95 100644 --- a/edit/editor.go +++ b/edit/editor.go @@ -353,7 +353,7 @@ MainLoop: continue MainLoop case syscall.SIGQUIT: // Emulate default behavior - sys.DumpStack() + print(sys.DumpStack()) os.Exit(1) default: // Other signals: turn off signal catching, and resend diff --git a/main.go b/main.go index b36f7ca1..a2330fa3 100644 --- a/main.go +++ b/main.go @@ -132,7 +132,7 @@ var usage = `Usage: func rescue() { r := recover() if r != nil { - sys.DumpStack() + print(sys.DumpStack()) println("execing recovery shell /bin/sh") syscall.Exec("/bin/sh", []string{}, os.Environ()) } diff --git a/sys/trace.go b/sys/dumpstack.go similarity index 75% rename from sys/trace.go rename to sys/dumpstack.go index 7a6930be..663f1bac 100644 --- a/sys/trace.go +++ b/sys/dumpstack.go @@ -2,10 +2,10 @@ package sys import "runtime" -func DumpStack() { +func DumpStack() string { buf := make([]byte, 1024) for runtime.Stack(buf, true) == cap(buf) { buf = make([]byte, cap(buf)*2) } - print(string(buf)) + return string(buf) }