diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 17:07:38 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 17:07:38 +0000 |
commit | 4b265d3e7bbb508bd0f846491b64ca06970bae60 (patch) | |
tree | e06afbd838ec192d1e454a255a77ad94a67279d5 | |
parent | 8428347e99598e7808575d97becfaf0c881af3cc (diff) | |
download | ruby-4b265d3e7bbb508bd0f846491b64ca06970bae60.tar.gz |
rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | file.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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 + * } * */ |