diff --git a/io.c b/io.c index 169158b..6a272c0 100644 --- a/io.c +++ b/io.c @@ -7343,9 +7343,38 @@ select_end(VALUE arg) * [, error_array * [, timeout]]] )-> array or nil * - * See Kernel#select. + * Calls select(2) system call. + * It returns an array that contains arrays of IO objects that are ready + * for * reading, are ready for writing, and have pending exceptions + * respectably. It returns nil on timeout. + * + * rp, wp = IO.pipe + * mesg = "ping " + * 100.times { + * rs, ws, = IO.select([rp], [wp]) + * if r = rs[0] + * ret = r.read(5) + * print ret + * case ret + * when /ping/ + * mesg = "pong\n" + * when /pong/ + * mesg = "ping " + * end + * end + * if w = ws[0] + * w.write(mesg) + * end + * } + * + * produces: + * + * ping pong + * ping pong + * ping pong + * (snipped) + * ping */ - static VALUE rb_f_select(int argc, VALUE *argv, VALUE obj) {