Bug #12257

io/wait: wait_readable/writable working different than when descriptor not open

Added by chucke (Tiago Cardoso) over 4 years ago. Updated 12 months ago.

Target version:


Coming from this pending issue:

Gist of it:

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

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

Updated by jeremyevans0 (Jeremy Evans) about 1 year ago

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


Updated by jeremyevans0 (Jeremy Evans) 12 months ago

  • Status changed from Open to Rejected

Also available in: Atom PDF