[DOC] Clarify IO#autoclose impact on #close
Mention that autoclose changes the behavior of explicit close in addition to implicit close at IO finalization.
This commit is contained in:
parent
62b3bcba5e
commit
47f8bf50e1
Notes:
git
2023-03-01 07:02:30 +00:00
12
io.c
12
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
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user