mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-13 20:28:32 +10:00
platform: Use new crash log api
This commit is contained in:
@@ -5,11 +5,10 @@ package libbox
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var stderrFile *os.File
|
||||
var crashOutputFile *os.File
|
||||
|
||||
func RedirectStderr(path string) error {
|
||||
if stats, err := os.Stat(path); err == nil && stats.Size() > 0 {
|
||||
@@ -27,12 +26,12 @@ func RedirectStderr(path string) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = unix.Dup2(int(outputFile.Fd()), int(os.Stderr.Fd()))
|
||||
err = debug.SetCrashOutput(outputFile, debug.CrashOptions{})
|
||||
if err != nil {
|
||||
outputFile.Close()
|
||||
os.Remove(outputFile.Name())
|
||||
return err
|
||||
}
|
||||
stderrFile = outputFile
|
||||
crashOutputFile = outputFile
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user