Method: IO.select

Defined in:
io.c

.select(read_array) ⇒ Object

[, error_array

[, timeout]]] )-> array  or  nil

See Kernel#select.



# File 'io.c'

/*
 *  call-seq:
 *     IO.select(read_array
 *               [, write_array
 *               [, error_array
 *               [, timeout]]] )-> array  or  nil
 *
 *  See <code>Kernel#select</code>.
 */

static VALUE
rb_f_select(int argc, VALUE *argv, VALUE obj)
{
    VALUE timeout;
    struct select_args args;
    struct timeval timerec;
    int i;

    rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout);
    if (NIL_P(timeout)) {
    args.timeout = 0;
    }
    else {
    timerec = rb_time_interval(timeout);
    args.timeout = &timerec;
    }

    for (i = 0; i < numberof(args.fdsets); ++i)
    rb_fd_init(&args.fdsets[i]);

#ifdef HAVE_RB_FD_INIT
    return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
#else
    return select_internal(args.read, args.write, args.except,
               args.timeout, args.fdsets);
#endif

}