From 2e00c6a32de997f60f216c04983dc774d0d45351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 5 Jul 2021 06:13:28 +0200 Subject: [PATCH] main: Don't log error for syncing /dev/stdout (#25703) --- tidb-server/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tidb-server/main.go b/tidb-server/main.go index b249a8a019a25..292f9a707f03c 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -17,6 +17,7 @@ import ( "context" "flag" "fmt" + "io/fs" "os" "runtime" "strconv" @@ -207,6 +208,12 @@ func exit() { func syncLog() { if err := log.Sync(); err != nil { + // Don't complain about /dev/stdout as Fsync will return EINVAL. + if pathErr, ok := err.(*fs.PathError); ok { + if pathErr.Path == "/dev/stdout" { + os.Exit(0) + } + } fmt.Fprintln(os.Stderr, "sync log err:", err) os.Exit(1) }