Method: Spitball::FileLock#acquire_lock
- Defined in:
- lib/spitball/file_lock.rb
#acquire_lock ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/spitball/file_lock.rb', line 11 def acquire_lock File.open(pre_lock_path, 'w') {|f| f.write Process.pid } system "ln #{pre_lock_path} #{path} > /dev/null 2>&1" File.read(path).to_i == Process.pid ensure FileUtils.rm_f pre_lock_path end |