summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--io.c14
2 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 3842b86c05..8433d76977 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 21 12:22:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_reopen): keep duplex pipe in correct mode for exception
+ safeness. fixed: [ruby-dev:25152]
+
Tue Dec 21 12:10:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/grid.rb: rescue bug of 'grid configure' on Tcl/Tk8.3-
@@ -43,7 +48,7 @@ Mon Dec 20 23:22:26 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
Mon Dec 20 22:56:39 2004 Tanaka Akira <akr@m17n.org>
- * gc.c (stack_end_address): gcc noinline attribute is available since
+ * gc.c (stack_end_address): gcc noinline attribute is available since
gcc-3.1.
Mon Dec 20 14:07:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
diff --git a/io.c b/io.c
index 7e4de96334..2a231298f3 100644
--- a/io.c
+++ b/io.c
@@ -3180,11 +3180,21 @@ io_reopen(io, nfile)
rb_sys_fail(orig->path);
}
else {
+ FILE *f2 = fptr->f2;
fclose(fptr->f);
- fptr->f = NULL;
+ fptr->f = f2;
+ fptr->f2 = NULL;
+ fptr->mode &= ~FMODE_READABLE;
if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);
- fptr->f = rb_fdopen(fd, mode);
+ if (f2) {
+ fptr->f = rb_fdopen(fd, "r");
+ fptr->f2 = f2;
+ fptr->mode |= FMODE_READABLE;
+ }
+ else {
+ fptr->f = rb_fdopen(fd, mode);
+ }
}
rb_thread_fd_close(fd);
if ((orig->mode & FMODE_READABLE) && pos >= 0) {