Project

General

Profile

Bug #12257

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

Added by chucke (Tiago Cardoso) over 3 years ago. Updated about 2 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:74840]

Description

Coming from this pending issue:

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

Gist of it:

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

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.

History

Updated by jeremyevans0 (Jeremy Evans) 3 months 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 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.

#2

Updated by jeremyevans0 (Jeremy Evans) about 2 months ago

  • Status changed from Open to Rejected

Also available in: Atom PDF