From 7dcf6be3a74335349aab5bd38fc96594761e5780 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 9 Nov 2019 09:14:32 +0300 Subject: [PATCH] Fix abort in GC_printf when gctest is built as WinMain executable (Cygwin) * misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)] (GC_printf): If WRITE(GC_stdout) failed but GC_stdout is GC_DEFAULT_STDOUT_FD then ignore the failure. * misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)] (GC_log_printf): If WRITE(GC_log) failed but GC_log is GC_DEFAULT_STDERR_FD then ignore the failure. --- misc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/misc.c b/misc.c index 438ef2c..1d35a19 100644 --- a/misc.c +++ b/misc.c @@ -1807,8 +1807,13 @@ void GC_printf(const char *format, ...) (void)WRITE(GC_stdout, buf, strlen(buf)); /* Ignore errors silently. */ # else - if (WRITE(GC_stdout, buf, strlen(buf)) < 0) + if (WRITE(GC_stdout, buf, strlen(buf)) < 0 +# if defined(CYGWIN32) || (defined(CONSOLE_LOG) && defined(MSWIN32)) + && GC_stdout != GC_DEFAULT_STDOUT_FD +# endif + ) { ABORT("write to stdout failed"); + } # endif } } @@ -1829,8 +1834,13 @@ void GC_log_printf(const char *format, ...) # ifdef NACL (void)WRITE(GC_log, buf, strlen(buf)); # else - if (WRITE(GC_log, buf, strlen(buf)) < 0) + if (WRITE(GC_log, buf, strlen(buf)) < 0 +# if defined(CYGWIN32) || (defined(CONSOLE_LOG) && defined(MSWIN32)) + && GC_log != GC_DEFAULT_STDERR_FD +# endif + ) { ABORT("write to GC log failed"); + } # endif } -- 2.7.4