Method: LockFile#lock
- Defined in:
- lib/bin_script/lock_file.rb
#lock(waiting_unlock = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bin_script/lock_file.rb', line 16 def lock(waiting_unlock = false) flags = File::WRONLY | File::TRUNC | File::CREAT @f = File.open(@path, flags) flags = File::LOCK_EX flags |= File::LOCK_NB if waiting_unlock == false unless @f.flock flags log "File '#{@path}' already open in exclusive mode.\n" return true end return false end |