diff --git a/main.go b/main.go index 59472e826..ac449541a 100644 --- a/main.go +++ b/main.go @@ -264,6 +264,13 @@ func main() { if err != nil { l.ErrorContext(ctx, "running dnsproxy", slogutil.KeyError, err) + // As defers are skipped in case of os.Exit, close logOutput manually. + // + // TODO(a.garipov): Consider making logger.Close method. + if logOutput != os.Stdout { + _ = logOutput.Close() + } + os.Exit(osutil.ExitCodeFailure) } }