1Panel/core/log/dup_write_darwin.go
ssongliu 2ef7b8b3b1
Some checks failed
sync2gitee / repo-sync (push) Failing after -6m49s
feat: core 功能代码拆分
2024-07-19 19:04:11 +08:00

20 lines
342 B
Go

package log
import (
"golang.org/x/sys/unix"
"os"
"runtime"
)
var stdErrFileHandler *os.File
func dupWrite(file *os.File) error {
stdErrFileHandler = file
if err := unix.Dup2(int(file.Fd()), int(os.Stderr.Fd())); err != nil {
return err
}
runtime.SetFinalizer(stdErrFileHandler, func(fd *os.File) {
fd.Close()
})
return nil
}