From 381821deea75d11a496401256c0267f2ff53183e Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 8 Feb 2012 01:55:01 +0000 Subject: merge revision(s) 34116: * ext/readline/readline.c (readline_readline): check if outstream is closed to get rid of a bug of readline 6. [ruby-dev:45043] [Bug #5803] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/readline/readline.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ext') diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 3114b38bd3..34ce023bea 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -40,6 +40,10 @@ #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif + static VALUE mReadline; #define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper" @@ -372,6 +376,13 @@ readline_readline(int argc, VALUE *argv, VALUE self) } if (!isatty(fileno(rl_instream)) && errno == EBADF) rb_raise(rb_eIOError, "closed stdin"); + if (rl_outstream) { + struct stat stbuf; + int fd = fileno(rl_outstream); + if (fd < 0 || fstat(fd, &stbuf) != 0) { + rb_raise(rb_eIOError, "closed stdout"); + } + } #ifdef _WIN32 rl_prep_terminal(1); -- cgit v1.2.3