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 <Eina.h>

#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
This commit is contained in:
Vincent Torri 2020-07-19 18:27:49 +01:00 committed by Carsten Haitzler (Rasterman)
parent d6f210b3a0
commit a9710f54c1
1 changed files with 8 additions and 0 deletions

View File

@ -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;