handle empty lockfiles

This commit is contained in:
Ward Wouts 2003-08-14 15:33:04 +00:00
parent d62c5c33e5
commit 6fcfacfad9

View file

@ -1,6 +1,6 @@
#!/usr/local/bin/ruby -w
# $Dwarf: ripnews.rb,v 1.75 2003/07/13 11:18:09 ward Exp $
# $Dwarf: ripnews.rb,v 1.76 2003/07/20 20:32:01 ward Exp $
# $Source$
#
@ -260,6 +260,7 @@ def lock
lock = File.open(@config[group]["LOCKFILE"], "r")
line = lock.gets
lock.close
if line
line.chomp!
psauxw = `ps -auxw`
if /^\S+\s+#{line}\s+/.match(psauxw)
@ -269,6 +270,10 @@ def lock
print "Stale lock found... removing...\n"
File.unlink(@config[group]["LOCKFILE"])
end
else
print "Empty lockfile found... removing...\n"
File.unlink(@config[group]["LOCKFILE"])
end
end
lock = File.new(@config[group]["LOCKFILE"], "w")
lock.print "#{Process.pid}\n"