| Class | Puppet::Util::Pidlock |
| In: |
lib/puppet/util/pidlock.rb
|
| Parent: | Object |
| lockfile | [R] |
# File lib/puppet/util/pidlock.rb, line 6 6: def initialize(lockfile) 7: @lockfile = lockfile 8: end
# File lib/puppet/util/pidlock.rb, line 19
19: def anonymous?
20: return false unless File.exists?(@lockfile)
21: File.read(@lockfile) == ""
22: end
# File lib/puppet/util/pidlock.rb, line 24
24: def lock(opts = {})
25: opts = {:anonymous => false}.merge(opts)
26:
27: if locked?
28: mine?
29: else
30: if opts[:anonymous]
31: File.open(@lockfile, 'w') { |fd| true }
32: else
33: File.open(@lockfile, "w") { |fd| fd.write(Process.pid) }
34: end
35: true
36: end
37: end
# File lib/puppet/util/pidlock.rb, line 10
10: def locked?
11: clear_if_stale
12: File.exists? @lockfile
13: end