[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Exclusive lock of a file

Sea&Gull

1/11/2005 3:03:00 PM

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!

--
s&g
2 Answers

Bill Atkins

1/11/2005 3:20:00 PM

0

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

On Wed, 12 Jan 2005 00:11:19 +0900, Sea&Gull <v@vsu.ru> wrote:
> 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!
>
> --
> s&g
>
>


--
$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"


Bill Atkins

1/11/2005 3:21:00 PM

0

Actually, that should be File::LOCK_EX.


On Tue, 11 Jan 2005 10:19:57 -0500, Bill Atkins <batkins57@gmail.com> wrote:
> File.open "filename" do |f|
> f.flock LOCK_EX
> ...
> end
>
> On Wed, 12 Jan 2005 00:11:19 +0900, Sea&Gull <v@vsu.ru> wrote:
> > 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!
> >
> > --
> > s&g
> >
> >
>
>
> --
> $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"
>


--
$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"