summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--io.c15
2 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f14f64952..58f842bbaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 26 10:47:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (pipe_open): avoid closing uninitialized file descriptors.
+ a patch from <tommy at tmtm.org> [ruby-dev:28600]
+
Mon Jun 26 09:56:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.[ch] (rb_w32_send, rb_w32_sendto): constified.
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 */