method
__write_nonblock
v2_5_5 -
Show latest stable
-
0 notes -
Class: IO
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
__write_nonblock(p1, p2)
private
Hide source
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); }