From: Matt Armstrong Date: 2002-02-05T03:51:47+09:00 Subject: Ruby bug? IO.close doesn't check for error It is possible for fclose() to fail (for example, when fclose() needs to flush buffers to disk and those writes fail due to a disk full condition). I was surprised to find that fptr_finalize did not check for this failure. I'd suggest something like the patch below. Index: io.c =================================================================== RCS file: /src/ruby/io.c,v retrieving revision 1.109 diff -u -r1.109 io.c --- io.c 2002/01/23 07:30:39 1.109 +++ io.c 2002/02/04 18:49:49 @@ -1075,11 +1075,19 @@ fptr_finalize(fptr) OpenFile *fptr; { + int save_errno = 0; if (fptr->f) { - fclose(fptr->f); + if (fclose(fptr->f) != 0) { + save_errno = errno; + } } if (fptr->f2) { - fclose(fptr->f2); + if (fclose(fptr->f2) != 0) { + save_errno = errno; + } + } + if (save_errno != 0) { + rb_sys_fail(fptr->path); } } -- matt