summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 11:57:55 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 11:57:55 +0000
commit5c6d11007b4a2b4333d8b836e64962e5d3a9a7a0 (patch)
treeee3c82962fb2288ea2f17c93d2440709cb1ff1f6 /io.c
parentf4325595ca86a248897e5c03685656437e5b485f (diff)
merges r24090 from trunk into ruby_1_9_1.
-- * io.c (pipe_open): handles leaked on win32 when an error occurs. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/io.c b/io.c
index 7c77358d7..e38d73acd 100644
--- a/io.c
+++ b/io.c
@@ -4650,9 +4650,19 @@ pipe_open(struct rb_exec_arg *eargp, VALUE prog, const char *modestr, int fmode,
rb_thread_sleep(1);
break;
default:
- if (eargp)
- rb_run_exec_options(&sarg, NULL);
- rb_sys_fail(cmd);
+ {
+ int e = errno;
+ if (eargp)
+ rb_run_exec_options(&sarg, NULL);
+ close(pair[0]);
+ close(pair[1]);
+ if ((fmode & (FMODE_READABLE|FMODE_WRITABLE)) == (FMODE_READABLE|FMODE_WRITABLE)) {
+ close(write_pair[0]);
+ close(write_pair[1]);
+ }
+ errno = e;
+ rb_sys_fail(cmd);
+ }
break;
}
}