Method: VagrantPlugins::SshConfigManager::FileLocker#locked?
- Defined in:
- lib/vagrant_ssh_config_manager/file_locker.rb
#locked? ⇒ Boolean
Check if file is currently locked by another process
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vagrant_ssh_config_manager/file_locker.rb', line 36 def locked? return false unless File.exist?(@file_path) begin File.open(@file_path, 'r') do |file| # Try to acquire a non-blocking exclusive lock file.flock(LOCK_EXCLUSIVE | LOCK_NON_BLOCKING) false # Not locked if we could acquire the lock end rescue Errno::EAGAIN, Errno::EACCES true # File is locked rescue StandardError => e @logger.debug("Error checking lock status: #{e.}") false end end |