Thank you Laurent,

A method File#flock() is available on Windows?
I wonder it may be available only on *nix.

  kwatch

Laurent Sansonetti <laurent / datarescue.be> wrote in message news:<3EAE2C6C.7020700 / datarescue.be>...
> Hi,
> 
> > Please show me a sample script.
> > 
> 
> Here is a test script I wrote a few days ago.  Do not expect good code, 
> it was just a test ;-)
> 
> # <-- CUT HERE
> FILENAME = "testfile"
> system("touch #{FILENAME}") or raise
> 
> processes = Array.new
> 3.times do |n|
>      n += 1
>      processes << fork do
>          f = File.new(FILENAME)
>          puts "Process: #{n}: getting lock"
>          f.flock(File::LOCK_EX);
>          puts "Process: #{n}: sleeping"
>          sleep 3
>          f.flock(File::LOCK_UN);
>          puts "Process: #{n}: released lock"
>      end
> end
> 
> puts "Father: waiting for children"
> processes.each { |pid| Process.waitpid(pid) }
> puts "Father: all children are terminated"
> # CUT HERE -->
> 
> I hope it will help you.
> 
> Cheers,