From f2128b58f2041eb910dcbca77b2a761ea35460d7 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Tue, 5 Feb 2019 23:26:46 -0500 Subject: [PATCH] Save errno value across logmsg() Need to be able to log messages without affecting errno. --- endlessh.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/endlessh.c b/endlessh.c index 4a71673..ea4b45b 100644 --- a/endlessh.c +++ b/endlessh.c @@ -42,6 +42,8 @@ static void logmsg(enum loglevel level, const char *format, ...) { if (loglevel >= level) { + int save = errno; + /* Print a timestamp */ long long now = uepoch(); time_t t = now / 1000; @@ -56,6 +58,8 @@ logmsg(enum loglevel level, const char *format, ...) vprintf(format, ap); va_end(ap); fputc('\n', stdout); + + errno = save; } }