flush()
public
Flushes any buffered data within ios to the underlying operating
system (note that this is Ruby
internal buffering only; the OS may buffer the data as well).
$stdout.print "no newline"
$stdout.flush
produces:
no newline
Show source
VALUE
rb_io_flush(VALUE io)
{
rb_io_t *fptr;
if (TYPE(io) != T_FILE) {
return rb_funcall(io, id_flush, 0);
}
io = GetWriteIO(io);
GetOpenFile(io, fptr);
if (fptr->mode & FMODE_WRITABLE) {
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
fsync(fptr->fd);
}
if (fptr->mode & FMODE_READABLE) {
io_unread(fptr);
}
return io;
}