From 077288bc6b6b138022d7f088c4f3db73cc2f35c7 Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 19 Jun 2012 17:07:33 +0900 Subject: [PATCH] set sync mode to write_io which is created by IO.pipe --- include/ruby/io.h | 1 + io.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/ruby/io.h b/include/ruby/io.h index e16ff11b7..6ebd58a90 100644 --- a/include/ruby/io.h +++ b/include/ruby/io.h @@ -59,6 +59,7 @@ long rb_io_primitive_read(struct rb_io_t *io_struct, char *buffer, long len); int rb_io_modestr_fmode(const char *modestr); int rb_io_modestr_oflags(const char *modestr); +void rb_io_synchronized(rb_io_t*); int rb_io_wait_readable(int fd); int rb_io_wait_writable(int fd); int rb_io_read_pending(rb_io_t *io_struct); diff --git a/io.c b/io.c index 164b31ff0..bebea8eee 100644 --- a/io.c +++ b/io.c @@ -487,6 +487,13 @@ prep_io(int fd, int mode, VALUE klass, const char *path) return io; } +void +rb_io_synchronized(rb_io_t *io_struct) +{ + rb_io_check_initialized(io_struct); + io_struct->mode |= FMODE_SYNC; +} + /* * call-seq: * ios.syswrite(string) => integer @@ -4328,6 +4335,8 @@ rb_io_s_pipe(VALUE recv, SEL sel, int argc, VALUE *argv) rd = prep_io(fd[0], FMODE_READABLE, recv, NULL); wr = prep_io(fd[1], FMODE_WRITABLE, recv, NULL); + rb_io_t *io_struct_wr = ExtractIOStruct(wr); + rb_io_synchronized(io_struct_wr); VALUE ret = rb_assoc_new(rd, wr); if (rb_block_given_p()) {