aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c7
1 files changed, 7 insertions, 0 deletions
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 <em>ios</em> is opened by <code>IO.popen</code>,
* <code>close</code> sets <code>$?</code>.
+ *
+ * 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;