2015-02-27 17:51:17 +01:00
|
|
|
// Log the panic under unix to the log file
|
|
|
|
|
2016-09-19 18:13:41 +02:00
|
|
|
// +build !windows,!solaris,!plan9
|
2015-02-27 17:51:17 +01:00
|
|
|
|
2016-08-04 23:18:56 +02:00
|
|
|
package cmd
|
2015-02-27 17:51:17 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
2016-09-07 22:21:58 +02:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2015-02-27 17:51:17 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// redirectStderr to the file passed in
|
|
|
|
func redirectStderr(f *os.File) {
|
2016-09-07 22:21:58 +02:00
|
|
|
err := unix.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
|
2015-02-27 17:51:17 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Failed to redirect stderr to file: %v", err)
|
|
|
|
}
|
|
|
|
}
|