Avoid duplicate fatal stderr output in GUI mode
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-09-17 18:20:27 +02:00
parent 9bdd642b97
commit 23283e3abd
3 changed files with 20 additions and 8 deletions

View file

@ -293,6 +293,7 @@ void log_error_errno(int err, const char* name)
/* print */
int msg_level = 0;
int msg_fatal_stderr = 1;
FILE* stdlog = 0;
int msg_line_prev = 0; /**< Previous line width on stdout */
int msg_line_curr = 0; /**< Current line width on stdout */
@ -393,15 +394,18 @@ void vlog_fatal(int err, const char* format, va_list ap, const char* post)
fflush(stdlog);
}
va_list ap_copy2;
va_copy(ap_copy2, ap);
vmsg(stderr, format, ap_copy2);
va_end(ap_copy2);
/* GUI consumers read tagged fatal messages from the log and must not receive a duplicate raw copy. */
if (!stdlog || msg_fatal_stderr) {
va_list ap_copy2;
va_copy(ap_copy2, ap);
vmsg(stderr, format, ap_copy2);
va_end(ap_copy2);
if (post)
msg(stderr, "%s", post);
if (post)
msg(stderr, "%s", post);
fflush(stderr);
fflush(stderr);
}
unlock_msg();
}