summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/log.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index e2963981fb..710859b8e7 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -251,6 +251,13 @@ int log_open(void) {
/* Do not call from library code. */
+ /* This function is often called in preparation for being able
+ * to log. Let's make sure we don't clobber errno, so that a call
+ * to a logging function immediately following a log_open() call
+ * can still easily reference an error that happened immediately
+ * before the log_open() call. */
+ PROTECT_ERRNO;
+
/* If we don't use the console we close it here, to not get
* killed by SAK. If we don't use syslog we close it here so
* that we are not confused by somebody deleting the socket in