mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-04 10:57:50 +08:00
sys.DumpStack now returns a string
This commit is contained in:
parent
6fcf7dba93
commit
67c2687a07
|
@ -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
|
||||
|
|
2
main.go
2
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())
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user