1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (fptr_finalize): ignore EBADF when f and f2 use same

descriptor.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-02-05 17:10:54 +00:00
parent 8210c254be
commit cc2ab3aca6
2 changed files with 16 additions and 7 deletions

View file

@ -1,3 +1,8 @@
Wed Feb 6 02:10:30 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* io.c (fptr_finalize): ignore EBADF when f and f2 use same
descriptor.
Tue Feb 5 16:17:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (fptr_finalize): should raise error when fclose fails.

18
io.c
View file

@ -1075,17 +1075,21 @@ static void
fptr_finalize(fptr, fin)
OpenFile *fptr;
{
int n1 = 0, n2 = 0, e = 0;
int n1 = 0, n2 = 0, e = 0, f1, f2 = -1;
if (fptr->f) {
n1 = fclose(fptr->f);
if (n1 < 0) e = errno;
}
if (fptr->f2) {
f2 = fileno(fptr->f2);
n2 = fclose(fptr->f2);
if (n2 < 0) e = errno;
}
if (fptr->f && fptr->f != fptr->f2) {
f1 = fileno(fptr->f);
n1 = fclose(fptr->f);
if (n1 < 0 && (e = errno) == EBADF && f1 == f2)
n1 = 0;
}
if (!fin && (n1 < 0 || n2 < 0)) {
if (n2 == 0) errno = e;
if (n1 == 0) errno = e;
rb_sys_fail(fptr->path);
}
}
@ -1644,7 +1648,7 @@ pipe_finalize(fptr)
#endif
rb_last_status = INT2FIX(status);
#else
fptr_finalize(fptr);
fptr_finalize(fptr, Qtrue);
#endif
pipe_del_fptr(fptr);
}