# class Puppet::Util::Pidlock

### Public Class Methods

new(lockfile) click to toggle source

    # File lib/puppet/util/pidlock.rb, line 6
    def initialize(lockfile)
      @lockfile = Puppet::Util::Lockfile.new(lockfile)
    end

### Public Instance Methods

lock() click to toggle source

    # File lib/puppet/util/pidlock.rb, line 19
    def lock
      return mine? if locked?

      @lockfile.lock(Process.pid)
    end

lock_pid() click to toggle source

    # File lib/puppet/util/pidlock.rb, line 33
    def lock_pid
      @lockfile.lock_data.to_i
    end

locked?() click to toggle source

    # File lib/puppet/util/pidlock.rb, line 10
    def locked?
      clear_if_stale
      @lockfile.locked?
    end

mine?() click to toggle source

    # File lib/puppet/util/pidlock.rb, line 15
    def mine?
      Process.pid == lock_pid
    end

unlock() click to toggle source

    # File lib/puppet/util/pidlock.rb, line 25
    def unlock()
      if mine?
        return @lockfile.unlock
      else
        false
      end
    end