зеркало из https://github.com/github/ruby.git
* 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:
Родитель
8210c254be
Коммит
cc2ab3aca6
|
@ -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
18
io.c
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче