aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2022-03-12 13:06:46 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-01 16:02:11 +0900
commit47f8bf50e1410223731e2b442ad5a6b9ea1106b5 (patch)
treed6a53d432bbfdc350ed964e0129dbe2d6ac35577 /io.c
parent62b3bcba5ee422d7431f90567636155358234288 (diff)
downloadruby-47f8bf50e1410223731e2b442ad5a6b9ea1106b5.tar.gz
[DOC] Clarify IO#autoclose impact on #close
Mention that autoclose changes the behavior of explicit close in addition to implicit close at IO finalization.
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 6 insertions, 6 deletions
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
*/