diff options
| author | Drew DeVault <sir@cmpwn.com> | 2018-03-27 22:55:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-27 22:55:08 -0400 |
| commit | f99a653bd3c48c8be300bd98f89789055f55962d (patch) | |
| tree | fe543d53153bd99b29d754c3ee4d0c6bbcab3d10 /common/log.c | |
| parent | ef169fcaeb17ec40cf83e54bba2ddbdcff10936f (diff) | |
| parent | 125d4fdf2e575b53d7c36b5147cf34c99516856f (diff) | |
Merge pull request #1639 from taiyu-len/save_errno
save errno to avoid issues with it being overwritten in sway_log_errno
Diffstat (limited to 'common/log.c')
| -rw-r--r-- | common/log.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/log.c b/common/log.c index 6dc9d743..1b46d58f 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,13 +146,14 @@ 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"); } fprintf(stderr, "\n"); } + errno = errsv; } bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) { |
