Skip to content

Commit

Permalink
set sync mode to write_io which is created by IO.pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jun 20, 2012
1 parent a9070e0 commit 077288b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/ruby/io.h
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions io.c
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 077288b

Please sign in to comment.