cleaner lock file checking, don't use 'ps'
This commit is contained in:
parent
42347d5f66
commit
1a1ed818f4
1 changed files with 7 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby -w
|
#!/usr/local/bin/ruby -w
|
||||||
|
|
||||||
# $Dwarf: ripnews.rb,v 1.90 2005/01/30 14:47:00 ward Exp $
|
# $Dwarf: ripnews.rb,v 1.91 2005/01/30 18:43:17 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -315,15 +315,15 @@ def lock
|
||||||
if @config[group].has_key?("LOCKFILE")
|
if @config[group].has_key?("LOCKFILE")
|
||||||
if FileTest.exists?(@config[group]["LOCKFILE"])
|
if FileTest.exists?(@config[group]["LOCKFILE"])
|
||||||
lock = File.open(@config[group]["LOCKFILE"], "r")
|
lock = File.open(@config[group]["LOCKFILE"], "r")
|
||||||
line = lock.gets
|
pid = lock.gets
|
||||||
lock.close
|
lock.close
|
||||||
if line
|
if pid
|
||||||
line.chomp!
|
pid.chomp!
|
||||||
psauxw = `ps auxw`
|
begin
|
||||||
if /^\S+\s+#{line}\s+/.match(psauxw)
|
Process.kill(0, pid)
|
||||||
print "Already running, exiting...\n"
|
print "Already running, exiting...\n"
|
||||||
exit
|
exit
|
||||||
else
|
rescue Errno::ESRCH
|
||||||
print "Stale lock found... removing...\n"
|
print "Stale lock found... removing...\n"
|
||||||
File.unlink(@config[group]["LOCKFILE"])
|
File.unlink(@config[group]["LOCKFILE"])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue