|
|
|
There may be a good chance that just opening in/out/err as NIO channels will "just work" so we should give that a shot for 1.1.
I did some research on this, and unfortunately the stdio streams provided from Java are not selectable. You can turn them into channels, but you can't get selectable channels. So it appears we'll need to do something different for this.
Currently the selection code quietly does nothing if the target IO is not selectable. This is why it waits for 20 seconds no matter what; select doesn't actually select on anything. There are a couple alternatives to this:
And I'm open to suggestions. The bottom line, however, is that stdio is not selectable on the JVM. Bummer. Perhaps we can implement a Selector for them and then use nio Pipe (with some scary thread magic)? One level less pretty too...
Less pretty is an understatement, but it might work. I don't want to implement it though
Removing target release from issues that fit any of the following criteria:
Since the related issue was closed as duplicate of this one, it's worth noting here that not only STDIO is non-selectable, but also any file-based streams, which seems to be a important limitation.
There's going to be support in NIO2 for registering arbitrary selector providers, which could potentially make selecting on stdio possible. But for now this remains unfixable without native code.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The way we get stdin is not compatible with nio. We basically (and even this is not neccesarily true) System.in. This is not an NIO friendly way to do this. It looks like we can new FileInputStream(FileDescriptor.in) and then we can get a selectable channel. Sounds easy until you see how many pesky details need to be rearranged to support this. We also implemented our own bufferedStream on top of stdin which extends a pushback stream.