]> granicus.if.org Git - gc/commitdiff
Prevent abort on GC_err/warn_printf write failure
authorIvan Maidanski <ivmai@mail.ru>
Mon, 10 Dec 2012 03:46:03 +0000 (07:46 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 10 Dec 2012 10:46:30 +0000 (14:46 +0400)
* misc.c (GC_LOG_PRINTF_IMPL, GC_warn_printf): Do not abort in case of
failure of write which duplicates message to log/stderr (if
GC_ANDROID_LOG).
* misc.c (GC_err_puts): Do not abort in case of stderr write failure.

misc.c

diff --git a/misc.c b/misc.c
index 14c43a74c25b4700aa2883f2db294898519f4113..b92aea83a7f99b6c1e87c9529a9820bea7d6705e 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1555,9 +1555,8 @@ void GC_err_printf(const char *format, ...)
           char buf[BUFSZ + 1]; \
           GC_PRINTF_FILLBUF(buf, format); \
           __android_log_write(loglevel, GC_ANDROID_LOG_TAG, buf); \
-          if (GC_log != GC_DEFAULT_STDERR_FD && (fileLogCond) \
-              && WRITE(GC_log, buf, strlen(buf)) < 0) \
-            ABORT("write to GC log file failed"); \
+          if (GC_log != GC_DEFAULT_STDERR_FD && (fileLogCond)) \
+            (void)WRITE(GC_log, buf, strlen(buf)); /* ignore errors */ \
         }
 
   void GC_log_printf(const char *format, ...)
@@ -1582,9 +1581,8 @@ void GC_err_printf(const char *format, ...)
 
     GC_PRINTF_FILLBUF(buf, format);
     __android_log_write(ANDROID_LOG_WARN, GC_ANDROID_LOG_TAG, buf);
-    if (GC_real_print_stats && GC_stderr != GC_DEFAULT_STDERR_FD
-        && WRITE(GC_stderr, buf, strlen(buf)) < 0)
-      ABORT("write to stderr failed");
+    if (GC_real_print_stats && GC_stderr != GC_DEFAULT_STDERR_FD)
+      (void)WRITE(GC_stderr, buf, strlen(buf)); /* ignore errors */
   }
 
 #endif /* GC_ANDROID_LOG */
@@ -1596,7 +1594,7 @@ void GC_err_puts(const char *s)
       if (GC_stderr == GC_DEFAULT_STDERR_FD)
         return; /* skip duplicate write to stderr */
 #   endif
-    if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed");
+    (void)WRITE(GC_stderr, s, strlen(s)); /* ignore errors */
 }
 
 STATIC void GC_CALLBACK GC_default_warn_proc(char *msg, GC_word arg)