1Panel/backend/log/dup_write_linux_arm64.go

21 lines
334 B
Go
Raw Normal View History

package log
import (
"os"
"runtime"
"syscall"
)
var stdErrFileHandler *os.File
func dupWrite(file *os.File) error {
stdErrFileHandler = file
2023-03-09 10:52:37 +08:00
if err := syscall.Dup3(int(file.Fd()), int(os.Stderr.Fd()), 0); err != nil {
return err
}
runtime.SetFinalizer(stdErrFileHandler, func(fd *os.File) {
fd.Close()
})
return nil
}