aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/io.c b/io.c
index e8007819b2..8927fad927 100644
--- a/io.c
+++ b/io.c
@@ -3029,8 +3029,14 @@ pipe_open(int argc, VALUE *argv, const char *mode)
/* parent */
if (pid == -1) {
int e = errno;
- close(arg.pair[0]);
- close(arg.pair[1]);
+ if ((modef & FMODE_READABLE)) {
+ close(arg.pair[0]);
+ close(arg.pair[1]);
+ }
+ if ((modef & FMODE_WRITABLE)) {
+ close(arg.pair[0]);
+ close(arg.pair[1]);
+ }
errno = e;
rb_sys_fail(cmd);
}