Skip to content

Commit

Permalink
main: Don't log error for syncing /dev/stdout (pingcap#25703)
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden authored Jul 5, 2021
1 parent de3c30b commit 2e00c6a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"flag"
"fmt"
"io/fs"
"os"
"runtime"
"strconv"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2e00c6a

Please sign in to comment.