method
__write_nonblock
ruby latest stable - Class:
IO
__write_nonblock(p1, p2)private
No documentation available.
static VALUE
io_write_nonblock(VALUE io, VALUE str, VALUE ex)
{
rb_io_t *fptr;
long n;
if (!RB_TYPE_P(str, T_STRING))
str = rb_obj_as_string(str);
io = GetWriteIO(io);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
if (io_fflush(fptr) < 0)
rb_sys_fail(0);
rb_io_set_nonblock(fptr);
n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
RB_GC_GUARD(str);
if (n == -1) {
int e = errno;
if (e == EWOULDBLOCK || e == EAGAIN) {
if (ex == Qfalse) {
return sym_wait_writable;
}
else {
rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e, "write would block");
}
}
rb_syserr_fail_path(e, fptr->pathv);
}
return LONG2FIX(n);
}