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