From 97ad9ab9841a438801b7feabf7b9fb238e8b5012 Mon Sep 17 00:00:00 2001 From: taiyu Date: Tue, 27 Mar 2018 02:59:41 -0700 Subject: save errno to avoid issues with it being overwritten --- common/log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/log.c b/common/log.c index 6dc9d743..877534c8 100644 --- a/common/log.c +++ b/common/log.c @@ -127,6 +127,7 @@ void _sway_abort(const char *filename, int line, const char* format, ...) { } void sway_log_errno(log_importance_t verbosity, char* format, ...) { + int errsv = errno; if (verbosity <= v) { unsigned int c = verbosity; if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { @@ -145,7 +146,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { va_end(args); fprintf(stderr, ": "); - fprintf(stderr, "%s", strerror(errno)); + fprintf(stderr, "%s", strerror(errsv)); if (colored && isatty(STDERR_FILENO)) { fprintf(stderr, "\x1B[0m"); -- cgit v1.2.3-54-g00ecf From 125d4fdf2e575b53d7c36b5147cf34c99516856f Mon Sep 17 00:00:00 2001 From: taiyu Date: Tue, 27 Mar 2018 19:33:59 -0700 Subject: restore errno --- common/log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/log.c b/common/log.c index 877534c8..1b46d58f 100644 --- a/common/log.c +++ b/common/log.c @@ -153,6 +153,7 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { } fprintf(stderr, "\n"); } + errno = errsv; } bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) { -- cgit v1.2.3-54-g00ecf