Skip to content

Commit 863d166

Browse files
authored
Merge pull request bnb-chain#3043 from fjl/windows-fix-fatalf
cmd/utils: don't check for stderr redirect on windows
2 parents 61734cc + b04219f commit 863d166

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎cmd/utils/cmd.go‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"os"
2424
"os/signal"
2525
"regexp"
26+
"runtime"
2627

2728
"github.com/ethereum/go-ethereum/common"
2829
"github.com/ethereum/go-ethereum/core"
@@ -52,10 +53,16 @@ func openLogFile(Datadir string, filename string) *os.File {
5253
// is redirected to a different file.
5354
func Fatalf(format string, args ...interface{}) {
5455
w := io.MultiWriter(os.Stdout, os.Stderr)
55-
outf, _ := os.Stdout.Stat()
56-
errf, _ := os.Stderr.Stat()
57-
if outf != nil && errf != nil && os.SameFile(outf, errf) {
58-
w = os.Stderr
56+
if runtime.GOOS == "windows" {
57+
// The SameFile check below doesn't work on Windows.
58+
// stdout is unlikely to get redirected though, so just print there.
59+
w = os.Stdout
60+
} else {
61+
outf, _ := os.Stdout.Stat()
62+
errf, _ := os.Stderr.Stat()
63+
if outf != nil && errf != nil && os.SameFile(outf, errf) {
64+
w = os.Stderr
65+
}
5966
}
6067
fmt.Fprintf(w, "Fatal: "+format+"\n", args...)
6168
logger.Flush()

0 commit comments

Comments
 (0)