summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/io.c b/io.c
index 44e2a11211..dd1058455a 100644
--- a/io.c
+++ b/io.c
@@ -3798,7 +3798,12 @@ rb_obj_display(int argc, VALUE *argv, VALUE self)
void
rb_write_error2(const char *mesg, long len)
{
- rb_io_write(rb_stderr, rb_str_new(mesg, len));
+ if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
+ fwrite(mesg, sizeof(char), len, stderr);
+ }
+ else {
+ rb_io_write(rb_stderr, rb_str_new(mesg, len));
+ }
}
void