summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-05 15:02:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-05 15:02:10 +0000
commite260f2a225c74e9d0c430c2363e681dfd16718b2 (patch)
tree012bb82624ef9b06f9c390928225f08a2de6ae51
parent98a9949e2b5c5a74b70ddc7b16065a13464c831c (diff)
downloadruby-e260f2a225c74e9d0c430c2363e681dfd16718b2.tar.gz
ruby-e260f2a225c74e9d0c430c2363e681dfd16718b2.tar.xz
ruby-e260f2a225c74e9d0c430c2363e681dfd16718b2.zip
document a blocking behavior of IO#eof?.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--io.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/io.c b/io.c
index c1081a746..474e20b9f 100644
--- a/io.c
+++ b/io.c
@@ -908,12 +908,31 @@ io_getc(OpenFile *fptr)
* ios.eof => true or false
* ios.eof? => true or false
*
- * Returns true if <em>ios</em> is at end of file. The stream must be
- * opened for reading or an <code>IOError</code> will be raised.
+ * Returns true if <em>ios</em> is at end of file that means
+ * there are no more data to read.
+ * The stream must be opened for reading or an <code>IOError</code> will be
+ * raised.
*
* f = File.new("testfile")
* dummy = f.readlines
* f.eof #=> true
+ *
+ * If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code>
+ * blocks until the other end sends some data or closes it.
+ *
+ * r, w = IO.pipe
+ * Thread.new { sleep 1; w.close }
+ * r.eof? #=> true after 1 second blocking
+ *
+ * r, w = IO.pipe
+ * Thread.new { sleep 1; w.puts "a" }
+ * r.eof? #=> false after 1 second blocking
+ *
+ * r, w = IO.pipe
+ * r.eof? # blocks forever
+ *
+ * Note that <code>IO#eof?</code> reads data to a input buffer.
+ * So <code>IO#sysread</code> doesn't work with <code>IO#eof?</code>.
*/
VALUE