From 8383c724a4d76ab031159115127b32619a151099 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 14 May 2019 21:55:24 +0200 Subject: [PATCH] main: not reopen /dev/stderr commit a1460818288b8addfe9b70c8931da83864251f7a introduced a change to write to /dev/stderr by default. Do not reopen the file in this case, but use directly the fd 2. Closes: https://github.com/opencontainers/runc/issues/2056 Closes: https://github.com/kubernetes/kubernetes/issues/77615 Closes: https://github.com/cri-o/cri-o/issues/2368 Signed-off-by: Giuseppe Scrivano --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 78913c04..3a8c1631 100644 --- a/main.go +++ b/main.go @@ -87,7 +87,7 @@ func main() { }, cli.StringFlag{ Name: "log", - Value: "/dev/stderr", + Value: "", Usage: "set the log file path where internal debug information is written", }, cli.StringFlag{ @@ -157,9 +157,15 @@ func (f *FatalWriter) Write(p []byte) (n int, err error) { } func createLogConfig(context *cli.Context) logs.Config { + logFilePath := context.GlobalString("log") + logPipeFd := "" + if logFilePath == "" { + logPipeFd = "2" + } config := logs.Config{ + LogPipeFd: logPipeFd, LogLevel: logrus.InfoLevel, - LogFilePath: context.GlobalString("log"), + LogFilePath: logFilePath, LogFormat: context.GlobalString("log-format"), } if context.GlobalBool("debug") {