From 64cca618ce0e26b035db6bb023edaaee01daf32c Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 26 Jun 2006 07:23:47 +0000 Subject: * io.c (pipe_open): avoid closing uninitialized file descriptors. a patch from [ruby-dev:28600] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 8fc095758..1b9cff03c 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 */ -- cgit