From 67c2687a07e98d4ac7d65e7eb3cb91e85ef5a3c1 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Wed, 3 Feb 2016 02:50:15 +0100 Subject: [PATCH] sys.DumpStack now returns a string --- edit/editor.go | 2 +- main.go | 2 +- sys/{trace.go => dumpstack.go} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename sys/{trace.go => dumpstack.go} (75%) 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) }