summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-24 17:07:38 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-24 17:07:38 +0000
commitcab461330ca14a055f26944cb861f31f861806c3 (patch)
treee06afbd838ec192d1e454a255a77ad94a67279d5
parentb200c643eb855767d7e5d0d94645fe97ea25b3e7 (diff)
downloadruby-cab461330ca14a055f26944cb861f31f861806c3.tar.gz
ruby-cab461330ca14a055f26944cb861f31f861806c3.tar.xz
ruby-cab461330ca14a055f26944cb861f31f861806c3.zip
rdoc update.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--file.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/file.c b/file.c
index 98f7ecf7d..7b4303acd 100644
--- a/file.c
+++ b/file.c
@@ -3499,7 +3499,19 @@ rb_thread_flock(void *data)
*
* Example:
*
- * File.new("testfile").flock(File::LOCK_UN) #=> 0
+ * # write lock
+ * # don't use "w" because it truncates the file before lock.
+ * File.open("testfile", File::WRONLY|File::CREAT, 0644) {|f|
+ * f.flock(File::LOCK_EX)
+ * f.truncate(0)
+ * f.write "new content"
+ * }
+ *
+ * # read lock
+ * File.open("testfile", "r") {|f|
+ * f.flock(File::LOCK_SH)
+ * p f.read
+ * }
*
*/