diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-24 01:56:36 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-24 01:56:36 +0000 |
commit | 1dec79c324d93b365f699bafa1a65de5752988ea (patch) | |
tree | 9978fb2a75dd991193660e4bf67c5aa6db1fd921 /ext/readline/readline.c | |
parent | 8397134330c388e562a8f7aa255b36dbcd7efecf (diff) | |
download | ruby-1dec79c324d93b365f699bafa1a65de5752988ea.tar.gz |
* 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/trunk@34116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/readline/readline.c')
-rw-r--r-- | ext/readline/readline.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index e8f9743426..888f5d847e 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -40,6 +40,10 @@ #include <unistd.h> #endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#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); |