mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
306a29980a
The builtin mechanism to capture a stacktrace in Go is to send a SIGQUIT to the running process. However, this mechanism is not avaiable on Windows. Thus, tweak the SIGINT handler to dump a stacktrace if the environment variable `RESTIC_DEBUG_STACKTRACE_SIGINT` is set.
15 lines
223 B
Go
15 lines
223 B
Go
package debug
|
|
|
|
import "runtime"
|
|
|
|
func DumpStacktrace() string {
|
|
buf := make([]byte, 128*1024)
|
|
|
|
for {
|
|
l := runtime.Stack(buf, true)
|
|
if l < len(buf) {
|
|
return string(buf[:l])
|
|
}
|
|
buf = make([]byte, len(buf)*2)
|
|
}
|
|
}
|