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,

--
Laurent