aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-09-26 23:23:26 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-09-28 18:32:06 +0800
commit25205d64d77d0dca5cb5fffac3df5b66036a4d2b (patch)
tree7600d8e572a5b8d79f6d8aec514dee0bbd5936f8 /cmd
parent03b2f56485fb1afe94a59f354df1ef50f0d06bc0 (diff)
downloadgo-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar.gz
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar.bz2
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar.lz
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar.xz
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.tar.zst
go-tangerine-25205d64d77d0dca5cb5fffac3df5b66036a4d2b.zip
[release/1.4.14] cmd/utils: don't check for stderr redirect on windows
The redirect check did not work on Go 1.6 and below because Stat returned an error for stdout and stderr. In Go 1.7 Stat works on stdout but doesn't return anything meaningful, causing cmd/geth test failures because the message is printed to stderr only. Fix it by printing to stdout only. (cherry picked from commit b04219fdbbef06527f77e93129d6a196b6841f44)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/utils/cmd.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 3b521a0e1..584afc804 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"regexp"
+ "runtime"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
@@ -52,10 +53,16 @@ func openLogFile(Datadir string, filename string) *os.File {
// is redirected to a different file.
func Fatalf(format string, args ...interface{}) {
w := io.MultiWriter(os.Stdout, os.Stderr)
- outf, _ := os.Stdout.Stat()
- errf, _ := os.Stderr.Stat()
- if outf != nil && errf != nil && os.SameFile(outf, errf) {
- w = 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()
+ errf, _ := os.Stderr.Stat()
+ if outf != nil && errf != nil && os.SameFile(outf, errf) {
+ w = os.Stderr
+ }
}
fmt.Fprintf(w, "Fatal: "+format+"\n", args...)
logger.Flush()