summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-26 07:23:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-26 07:23:47 +0000
commite510c0e71f365afcb79340a4002f652be671443a (patch)
tree676392b6e65a3a36e14390fc60244aa1e3d5caea /io.c
parentd2de06548d05f6de77fd2a8ed6ba60edbb507ba4 (diff)
* io.c (pipe_open): avoid closing uninitialized file descriptors.
a patch from <tommy at tmtm.org> [ruby-dev:28600] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/io.c b/io.c
index 8fc0957582..1b9cff03c6 100644
--- a/io.c
+++ b/io.c
@@ -3136,8 +3136,19 @@ retry:
rb_thread_sleep(1);
goto retry;
}
- close(pr[0]); close(pw[1]);
- rb_sys_fail(pname);
+ else {
+ int e = errno;
+ if ((modef & FMODE_READABLE)) {
+ close(pr[0]);
+ close(pr[1]);
+ }
+ if ((modef & FMODE_WRITABLE)) {
+ close(pw[0]);
+ close(pw[1]);
+ }
+ errno = e;
+ rb_sys_fail(pname);
+ }
break;
default: /* parent */