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 #!/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$ # $Source$
# #
@ -260,13 +260,18 @@ def lock
lock = File.open(@config[group]["LOCKFILE"], "r") lock = File.open(@config[group]["LOCKFILE"], "r")
line = lock.gets line = lock.gets
lock.close lock.close
line.chomp! if line
psauxw = `ps -auxw` line.chomp!
if /^\S+\s+#{line}\s+/.match(psauxw) psauxw = `ps -auxw`
print "Already running, exiting...\n" if /^\S+\s+#{line}\s+/.match(psauxw)
exit print "Already running, exiting...\n"
exit
else
print "Stale lock found... removing...\n"
File.unlink(@config[group]["LOCKFILE"])
end
else else
print "Stale lock found... removing...\n" print "Empty lockfile found... removing...\n"
File.unlink(@config[group]["LOCKFILE"]) File.unlink(@config[group]["LOCKFILE"])
end end
end end