mirror of https://github.com/poanetwork/quorum.git
Merge pull request #3043 from fjl/windows-fix-fatalf
cmd/utils: don't check for stderr redirect on windows
This commit is contained in:
commit
863d166c7b
|
@ -23,6 +23,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
@ -52,11 +53,17 @@ func openLogFile(Datadir string, filename string) *os.File {
|
||||||
// is redirected to a different file.
|
// is redirected to a different file.
|
||||||
func Fatalf(format string, args ...interface{}) {
|
func Fatalf(format string, args ...interface{}) {
|
||||||
w := io.MultiWriter(os.Stdout, os.Stderr)
|
w := io.MultiWriter(os.Stdout, os.Stderr)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// The SameFile check below doesn't work on Windows.
|
||||||
|
// stdout is unlikely to get redirected though, so just print there.
|
||||||
|
w = os.Stdout
|
||||||
|
} else {
|
||||||
outf, _ := os.Stdout.Stat()
|
outf, _ := os.Stdout.Stat()
|
||||||
errf, _ := os.Stderr.Stat()
|
errf, _ := os.Stderr.Stat()
|
||||||
if outf != nil && errf != nil && os.SameFile(outf, errf) {
|
if outf != nil && errf != nil && os.SameFile(outf, errf) {
|
||||||
w = os.Stderr
|
w = os.Stderr
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fmt.Fprintf(w, "Fatal: "+format+"\n", args...)
|
fmt.Fprintf(w, "Fatal: "+format+"\n", args...)
|
||||||
logger.Flush()
|
logger.Flush()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue