From 8be4466d66ca58e09dcfa5e934bce090de4508fe Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 24 Dec 2021 11:05:47 +0100 Subject: [PATCH] src/main.go: in setLogFile() check for null when closing old FD and also check error from Close() --- src/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.go b/src/main.go index 006d096..fa6ccf7 100644 --- a/src/main.go +++ b/src/main.go @@ -54,9 +54,11 @@ func setLogFile() { log.Error(err.Error()) } - // Close old one (if open) - if logfd.Fd() < 0 { - logfd.Close() + // Try close if old descriptor is defined. + if logfd != nil { + if err = logfd.Close(); err != nil { + log.Error(err.Error()) + } } // Update variable and set log writer.