summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/io.c b/io.c
index 4cc8e749ed..59e5274ba1 100644
--- a/io.c
+++ b/io.c
@@ -5928,6 +5928,12 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
fp->encs = convconfig;
clear_codeconv(fp);
io_check_tty(fp);
+ if (fileno(stdin) == fd)
+ fp->stdio_file = stdin;
+ else if (fileno(stdout) == fd)
+ fp->stdio_file = stdout;
+ else if (fileno(stderr) == fd)
+ fp->stdio_file = stderr;
return io;
}