diff --git a/ChangeLog b/ChangeLog index 2a59f7c653..207630eb36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 24 19:59:56 2011 Tanaka Akira + + * io.c (rb_io_reopen): re-initialize buffereing mode for stdout and + stderr. + Thu Nov 24 11:12:48 2011 KOSAKI Motohiro * io.c (rb_io_fsync,rb_io_fdatasync): release GVL during fsync(). diff --git a/io.c b/io.c index 31b07f9c0a..3f35c1982c 100644 --- a/io.c +++ b/io.c @@ -6151,6 +6151,14 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file) if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0) rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv)); #endif + if (fptr->stdio_file == stderr) { + if (setvbuf(fptr->stdio_file, NULL, _IONBF, BUFSIZ) != 0) + rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv)); + } + else if (fptr->stdio_file == stdout && isatty(fptr->fd)) { + if (setvbuf(fptr->stdio_file, NULL, _IOLBF, BUFSIZ) != 0) + rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv)); + } } else { if (close(fptr->fd) < 0)