sys.DumpStack now returns a string

This commit is contained in:
Qi Xiao 2016-02-03 02:50:15 +01:00
parent 6fcf7dba93
commit 67c2687a07
3 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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())
}

View File

@ -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)
}