Exclusive lock of a file

S

Sea&Gull

Hi!

Could you please give me a hint how in Ruby
to open a file with exclusive lock?

As I know, in perl it is something like this:

open F, "filename";
flock F, 2



Thanks a lot!
 
B

Bill Atkins

Actually, that should be File::LOCK_EX.


File.open "filename" do |f|
f.flock LOCK_EX
...
end




--
$stdout.sync = true
"Just another Ruby hacker.".each_byte do |b|
('a'..'z').step do|c|print c+"\b";sleep 0.007 end;print b.chr
end; print "\n"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top