* fports.c: include gc.h.
authorGary Houston <ghouston@arglist.com>
Mon, 13 Nov 2000 23:16:38 +0000 (23:16 +0000)
committerGary Houston <ghouston@arglist.com>
Mon, 13 Nov 2000 23:16:38 +0000 (23:16 +0000)
(fport_flush, fport_close): silently ignore I/O errors when
closing a port during gc.  it's better than aborting in scm_error.

* throw.c (scm_handle_by_message): remove obsolete comment.

libguile/ChangeLog
libguile/fports.c
libguile/throw.c

index 03f7fb7..b284072 100644 (file)
@@ -1,3 +1,11 @@
+2000-11-13  Gary Houston  <ghouston@arglist.com>
+
+       * fports.c: include gc.h.
+       (fport_flush, fport_close): silently ignore I/O errors when
+       closing a port during gc.  it's better than aborting in scm_error.
+
+       * throw.c (scm_handle_by_message): remove obsolete comment.
+
 2000-11-12  Gary Houston  <ghouston@arglist.com>
 
        * fports.c (scm_open_file): fix the 'b' option.  Thanks
index a14130b..9438bbd 100644 (file)
@@ -48,8 +48,9 @@
 #include <fcntl.h>
 #include "libguile/_scm.h"
 #include "libguile/strings.h"
-
 #include "libguile/validate.h"
+#include "libguile/gc.h"
+
 #include "libguile/fports.h"
 
 #ifdef HAVE_STRING_H
@@ -643,9 +644,7 @@ fport_flush (SCM port)
                }
              pt->write_pos = pt->write_buf + remaining;
            }
-         if (!terminating)
-           scm_syserror ("fport_flush");
-         else
+         if (terminating)
            {
              const char *msg = "Error: could not flush file-descriptor ";
              char buf[11];
@@ -656,6 +655,14 @@ fport_flush (SCM port)
 
              count = remaining;
            }
+         else if (scm_gc_running_p)
+           {
+             /* silently ignore the error.  scm_error would abort if we
+                called it now.  */
+             count = remaining;
+           }
+         else
+           scm_syserror ("fport_flush");
        }
       ptr += count;
       remaining -= count;
@@ -694,7 +701,14 @@ fport_close (SCM port)
   fport_flush (port);
   SCM_SYSCALL (rv = close (fp->fdes));
   if (rv == -1 && errno != EBADF)
-    scm_syserror ("fport_close");
+    {
+      if (scm_gc_running_p)
+       /* silently ignore the error.  scm_error would abort if we
+          called it now.  */
+       ;
+      else
+       scm_syserror ("fport_close");
+    }
   if (pt->read_buf == pt->putback_buf)
     pt->read_buf = pt->saved_read_buf;
   if (pt->read_buf != &pt->shortbuf)
index afa9ffa..dfcb4c4 100644 (file)
@@ -485,9 +485,6 @@ scm_handle_by_message (void *handler_data, SCM tag, SCM args)
     }
 
   handler_message (handler_data, tag, args);
-  /* try to flush the error message first before the rest of the
-     ports: if any throw error, it currently causes a bus
-     exception.  */
   exit (2);
 }