[#103241] [Ruby master Bug#17777] 2.6.7 fails to build on macOS: implicit declaration of function 'rb_native_mutex_destroy' is invalid in C99 — eregontp@...
Issue #17777 has been reported by Eregon (Benoit Daloze).
17 messages
2021/04/05
[#103305] [Ruby master Feature#17785] Allow named parameters to be keywords — marcandre-ruby-core@...
Issue #17785 has been reported by marcandre (Marc-Andre Lafortune).
21 messages
2021/04/08
[#103342] [Ruby master Feature#17790] Have a way to clear a String without resetting its capacity — jean.boussier@...
Issue #17790 has been reported by byroot (Jean Boussier).
14 messages
2021/04/09
[#103388] [ANN] Multi-factor Authentication of bugs.ruby-lang.org — SHIBATA Hiroshi <hsbt@...>
Hello,
5 messages
2021/04/12
[#103414] Re: [ANN] Multi-factor Authentication of bugs.ruby-lang.org
— Martin J. Dürst <duerst@...>
2021/04/13
SXMgdGhlcmUgYSB3YXkgdG8gdXNlIHRoaXMgbXVsdGktZmFjdG9yIGF1dGhlbnRpY2F0aW9uIGZv
[#103547] List of CI sites to check — Martin J. Dürst <duerst@...>
SGVsbG8gZXZlcnlib2R5LAoKRHVlIHRvIHZhcmlvdXMgcGVyc29uYWwgcmVhc29ucywgSSBoYXZl
4 messages
2021/04/22
[#103596] [Ruby master Feature#17830] Add Integer#previous and Integer#prev — rafasoaresms@...
Issue #17830 has been reported by rafasoares (Rafael Soares).
9 messages
2021/04/26
[ruby-core:103649] [Ruby master Feature#16962] Make IO.for_fd autoclose option default to false
From:
merch-redmine@...
Date:
2021-04-29 00:07:57 UTC
List:
ruby-core #103649
Issue #16962 has been updated by jeremyevans0 (Jeremy Evans).
Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN)
Subject changed from IO.close behaviour to Make IO.for_fd autoclose option default to false
Tracker changed from Bug to Feature
I looked into this and I think it's because stdin, stdout, and stderr are special cased:
```c
if (IS_PREP_STDIO(fptr) || fd <= 2) {
/* need to keep FILE objects of stdin, stdout and stderr */
}
```
This Ruby program shows the expected behavior:
```ruby
out = STDOUT.dup
IO.for_fd(out.fileno, autoclose: true).close
out.puts "Hello World"
```
output:
```
-:3:in `write': Bad file descriptor @ io_writev - <STDOUT> (Errno::EBADF)
from -:3:in `puts'
from -:3:in `<main>'
```
I'm not sure it is worth documenting that `autoclose` does not affect stdin, stdout, or stderr.
I agree that `autoclose: false` is probably a better default. However, that's a feature request and not a bug fix. Updating subject and switching to feature.
----------------------------------------
Feature #16962: Make IO.for_fd autoclose option default to false
https://bugs.ruby-lang.org/issues/16962#change-91745
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
----------------------------------------
I discussed this with @eregon and I think the goal here is to try and figure out a way these interfaces can be a bit less confusing.
## 1. I don't understand this behaviour:
```ruby
STDOUT.close
STDOUT.puts "Hello World"
# => closed stream
```
vs
```ruby
IO.for_fd(STDOUT.fileno, autoclose: true).close
STDOUT.puts "Hello World"
# => Hello World
```
## 2. `IO.for_fd(..., autoclose: true/false)`
The documentation for `autoclose` is:
> If the value is false, the fd will be kept open after this IO instance gets finalized.
But it also seems to affect `#close` - i.e. calling close does not close underlying file descriptor.
Should we fix the documentation or is the implementation wrong? Maybe the name `autoclose:` is very confusing. My initial interpretation was it was just 'automatically close this I/O when it is garbage collected'.
## 3. `IO.for_fd(..., autoclose: false)` default
In most cases, it seems like `autoclose: false` would make more sense as the default, since the file descriptor must come from some other place.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>