Project

General

Profile

Bug #3728 ยป issue3728.patch

eitoball (Eito Katagiri), 09/24/2010 11:40 PM

View differences:

io.c
7339 7339
 *     IO.select(read_array
7340 7340
 *               [, write_array
7341 7341
 *               [, error_array
7342
 *               [, timeout]]] )-> array  or  nil
7342
 *               [, timeout]]]) -> array  or  nil
7343 7343
 *
7344
 *  See <code>Kernel#select</code>.
7344
 *  Calls select(2) system call.
7345
 *  It monitors given arrays of <code>IO</code> objects, waits one or more
7346
 *  of <code>IO</code> objects ready for reading, are ready for writing,
7347
 *  and have pending exceptions respectably, and returns an array that
7348
 *  contains arrays of those IO objects.  It will return <code>nil</code>
7349
 *  if optional <i>timeout</i> value is given and no <code>IO</code> object
7350
 *  is ready in <i>timeout</i> seconds.
7351
 *
7352
 *  === Parameters
7353
 *  read_array:: an array of <code>IO</code> objects that wait until ready for read
7354
 *  write_array:: an array of <code>IO</code> objects that wait until ready for write
7355
 *  error_array:: an array of <code>IO</code> objects that wait for exceptions
7356
 *  timeout:: a numeric value in second
7357
 *
7358
 *  === Example
7359
 *
7360
 *      rp, wp = IO.pipe
7361
 *      mesg = "ping "
7362
 *      100.times {
7363
 *        rs, ws, = IO.select([rp], [wp])
7364
 *        if r = rs[0]
7365
 *          ret = r.read(5)
7366
 *          print ret
7367
 *          case ret
7368
 *          when /ping/
7369
 *            mesg = "pong\n"
7370
 *          when /pong/
7371
 *            mesg = "ping "
7372
 *          end
7373
 *        end
7374
 *        if w = ws[0]
7375
 *          w.write(mesg)
7376
 *        end
7377
 *      }
7378
 *
7379
 *  <em>produces:</em>
7380
 *
7381
 *      ping pong
7382
 *      ping pong
7383
 *      ping pong
7384
 *      (snipped)
7385
 *      ping
7345 7386
 */
7346

  
7347 7387
static VALUE
7348 7388
rb_f_select(int argc, VALUE *argv, VALUE obj)
7349 7389
{