diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 65f4ea04c6..825e0e6829 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -503,7 +503,8 @@ readline_s_set_input(VALUE self, VALUE input) rb_sys_fail("fdopen"); } rl_instream = f; - ifp->stdio_file = f; + if (f == stdin) + ifp->stdio_file = f; readline_instream = input; } return input; @@ -558,7 +559,8 @@ readline_s_set_output(VALUE self, VALUE output) rb_sys_fail("fdopen"); } rl_outstream = f; - ofp->stdio_file = f; + if (f == stdout) + ofp->stdio_file = f; readline_outstream = output; } return output;