From 255955585c922ec5e303df184057b7781fcee345 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 15 Jan 2015 15:26:03 +0000 Subject: * io.c (rb_io_close_m): Don't raise when the IO object is closed. [ruby-core:67444] [Feature #10718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index c9849715c0..c99f0c2a7e 100644 --- a/io.c +++ b/io.c @@ -4415,11 +4415,18 @@ rb_io_close(VALUE io) * * If ios is opened by IO.popen, * close sets $?. + * + * Calling this method on closed IO object is just ignored since Ruby 2.3. */ static VALUE rb_io_close_m(VALUE io) { + rb_io_t *fptr = RFILE(io)->fptr; + rb_io_check_initialized(fptr); + if (fptr->fd < 0) { + return Qnil; + } rb_io_check_closed(RFILE(io)->fptr); rb_io_close(io); return Qnil; -- cgit v1.2.3