Created
October 17, 2011 13:12
-
-
Save sneakin/1292579 to your computer and use it in GitHub Desktop.
jRuby IO.select fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This should print "nada" unless stdin has data. | |
while true | |
i, o, e = IO.select([$stdin], nil, nil, 0) | |
if i.include?($stdin) | |
c = $stdin.readpartial(1024) | |
puts c.inspect | |
else | |
puts "nada" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the beginning of the execution of this script, there is nothing in
$stdin
, so this script block on line 7.If you feed some stuff on
$stdin
in the beginning, the script will terminate as expected. For example: