From 47f8bf50e1410223731e2b442ad5a6b9ea1106b5 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 12 Mar 2022 13:06:46 +0100 Subject: [DOC] Clarify IO#autoclose impact on #close Mention that autoclose changes the behavior of explicit close in addition to implicit close at IO finalization. --- io.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index dcc9d9b038..a3dfa027d4 100644 --- a/io.c +++ b/io.c @@ -9549,7 +9549,7 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass) * ios.autoclose? -> true or false * * Returns +true+ if the underlying file descriptor of _ios_ will be - * closed automatically at its finalization, otherwise +false+. + * closed at its finalization or at calling #close, otherwise +false+. */ static VALUE @@ -9567,13 +9567,13 @@ rb_io_autoclose_p(VALUE io) * Sets auto-close flag. * * f = open("/dev/null") - * IO.for_fd(f.fileno) - * # ... - * f.gets # may cause Errno::EBADF + * IO.for_fd(f.fileno).close + * f.gets # raises Errno::EBADF * * f = open("/dev/null") - * IO.for_fd(f.fileno).autoclose = false - * # ... + * g = IO.for_fd(f.fileno) + * g.autoclose = false + * g.close * f.gets # won't cause Errno::EBADF */ -- cgit v1.2.1