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
|
||||
|
||||
# $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$
|
||||
|
||||
#
|
||||
|
|
@ -315,15 +315,15 @@ def lock
|
|||
if @config[group].has_key?("LOCKFILE")
|
||||
if FileTest.exists?(@config[group]["LOCKFILE"])
|
||||
lock = File.open(@config[group]["LOCKFILE"], "r")
|
||||
line = lock.gets
|
||||
pid = lock.gets
|
||||
lock.close
|
||||
if line
|
||||
line.chomp!
|
||||
psauxw = `ps auxw`
|
||||
if /^\S+\s+#{line}\s+/.match(psauxw)
|
||||
if pid
|
||||
pid.chomp!
|
||||
begin
|
||||
Process.kill(0, pid)
|
||||
print "Already running, exiting...\n"
|
||||
exit
|
||||
else
|
||||
rescue Errno::ESRCH
|
||||
print "Stale lock found... removing...\n"
|
||||
File.unlink(@config[group]["LOCKFILE"])
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue