Issue #12257 has been updated by jeremyevans0 (Jeremy Evans).


I don't think this is a bug.  It makes sense for `IO#wait_writable` to raise an exception, because the specific `IO` instance will never be writable after `close_write`.  As the documentation for `IO.select` indicates, it calls `select(2)`, and returns arrays showing which `IO` objects you can take action on.  I don't think that it would make sense for `IO.select` to go through all input or output read and write arrays and check if the file descriptors are still open for the appropriate direction.  Even if it could, raising in that case would not be helpful, as you would lose information on which other file descriptors you could take action on.

One thing that may be helpful would be the addition of `IO#read_closed?` and `IO#write_closed?`, as currently I'm not sure how you can determine if an `IO` instance is closed in a given direction.  However, that would be a feature request, not a bug fix.

----------------------------------------
Bug #12257: io/wait: wait_readable/writable working different than IO.select when descriptor not open
https://bugs.ruby-lang.org/issues/12257#change-78895

* Author: chucke (Tiago Cardoso)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Coming from this pending issue:

https://github.com/net-ssh/net-ssh/pull/303

Gist of it:

<pre>
f = IO.popen("/bin/sh","r+")
f.close_write
f.wait_writable #=> IOError: not opened for writing
IO.select(nil,[f],nil,10) #=> no error
</pre>

The way I see it, it should have the same behaviour, i.e. either IO.select should complain, or wait_writable should just return nil. 





-- 
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>