# About
lockf.rb offers Ruby bindings for the advisory-mode lock provided
by the lockf(3) function. It is similar to flock(2) in spirit but
it also has semantic differences that can be desirable when used
across the fork(2) boundary and that is usually the main reason
to use this library.
# Example
#!/usr/bin/env ruby
require "lockf"
pids = []
lockf = Lockf.unlinked
5.times do
pids << fork {
puts "Wait for lock (pid #{Process.pid})"
lockf.synchronize do
puts "Lock acquired (pid #{Process.pid})"
sleep 5
end
}
end
pids.each { Process.wait(it) }
ยทยทยท
##
# Wait for lock (pid 12345)
# Lock acquired (pid 12345)
# ...
# Links
Best regards,
Robert
______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.org/