summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-10-06 02:45:15 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-10-06 02:45:15 +0000
commit6536fb84b35a5ef03fcc0b22cd34f1122d53d976 (patch)
treef6dc9277400077a0cc7c102fef65e72d11153938 /io.c
parent9d04ee7eddb098f0450f3e6b1c1ab5f6e81b3c48 (diff)
1.1c6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/io.c b/io.c
index c86409d0ea..04a8d67e5c 100644
--- a/io.c
+++ b/io.c
@@ -1359,12 +1359,15 @@ io_reopen(io, nfile)
mode = io_mode_string(fptr);
fd = fileno(fptr->f);
- if (fileno(fptr->f) < 3) {
+ if (fd < 3) {
/* need to keep stdio */
- dup2(fileno(orig->f), fd);
+ if (dup2(fileno(orig->f), fd) < 0)
+ rb_sys_fail(orig->path);
}
else {
fclose(fptr->f);
+ if (dup2(fileno(orig->f), fd) < 0)
+ rb_sys_fail(orig->path);
fptr->f = rb_fdopen(fd, mode);
}
@@ -1372,7 +1375,8 @@ io_reopen(io, nfile)
fd = fileno(fptr->f2);
fclose(fptr->f2);
if (orig->f2) {
- dup2(fileno(orig->f2), fd);
+ if (dup2(fileno(orig->f2), fd) < 0)
+ rb_sys_fail(orig->path);
fptr->f2 = rb_fdopen(fd, "w");
}
else {