public Method

IO.close

ios.close    nil

Closes ios and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an IOError is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector.

If ios is opened by IO.popen, close sets $?.

Source Code

/*
*  call-seq:
*     ios.close   => nil
*  
*  Closes <em>ios</em> and flushes any pending writes to the operating
*  system. The stream is unavailable for any further data operations;
*  an <code>IOError</code> is raised if such an attempt is made. I/O
*  streams are automatically closed when they are claimed by the
*  garbage collector.
*
*  If <em>ios</em> is opened by <code>IO.popen</code>,
*  <code>close</code> sets <code>$?</code>.
*/

static VALUE
rb_io_close_m(io)
   VALUE io;
{
   if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) {
       rb_raise(rb_eSecurityError, "Insecure: can't close");
   }
   rb_io_check_closed(RFILE(io)->fptr);
   rb_io_close(io);
   return Qnil;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.