From: Joel Rosdahl Date: Sat, 27 Aug 2022 19:56:03 +0000 (+0200) Subject: fix: Handle failure to write to stderr when failing to write to log file X-Git-Tag: v4.7~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11432b8c9c406a2084c1f1eec15703904251fd1e;p=thirdparty%2Fccache.git fix: Handle failure to write to stderr when failing to write to log file This can happen with CCACHE_LOGFILE=/dev/stdout ccache compiler ... |& head -n 1 or similar. --- diff --git a/src/Logging.cpp b/src/Logging.cpp index 46b62f554..82e4b1c23 100644 --- a/src/Logging.cpp +++ b/src/Logging.cpp @@ -66,10 +66,14 @@ bool debug_log_enabled = false; print_fatal_error_and_exit() { // Note: Can't throw Fatal since that would lead to recursion. - PRINT(stderr, - "ccache: error: Failed to write to {}: {}\n", - logfile_path, - strerror(errno)); + try { + PRINT(stderr, + "ccache: error: Failed to write to {}: {}\n", + logfile_path, + strerror(errno)); + } catch (std::runtime_error&) { + // Ignore since we can't do anything about it. + } exit(EXIT_FAILURE); }