From a9710f54c1732543f57b9a44134e406b21eba93c Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sun, 19 Jul 2020 18:27:49 +0100 Subject: [PATCH] Eina log: flush stderr on mintty-based terminals Summary: on those terminal, stderr is never flushed, so errors messages are not displayed when, for example, the app crashes Test Plan: test program : ```#include #define ERR(...) EINA_LOG_DOM_ERR(log_dom, __VA_ARGS__) int main() { int log_dom = -1; eina_init(); log_dom = eina_log_domain_register("eet", EINA_COLOR_CYAN); if (log_dom < 0) { printf("error register\n"); return 0; } ERR("an error."); while (1) { } return 0; } ``` without the patch, nothing is displayed, even after a Ctrl-C to finish the program with the patch, the error message is displayed Reviewers: raster Reviewed By: raster Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12058 --- src/lib/eina/eina_log.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/eina/eina_log.c b/src/lib/eina/eina_log.c index d05aa22830..31a5871a94 100644 --- a/src/lib/eina/eina_log.c +++ b/src/lib/eina/eina_log.c @@ -2052,6 +2052,14 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d, vfprintf(stderr, fmt, args); putc('\n', stderr); DISPLAY_BACKTRACE(stderr, level); +# ifdef _WIN32 + /* + * NOTE: when using mintty-base terminals (like MSYS2, or cygwin one), + * stderr is not flushed, so we force flush in this case. + */ + if (!_eina_log_win32_is_console) + fflush(stderr); +# endif #else (void) d; (void) level;