From 6fcfacfad9c6062b9a7ef558aca656bdda58e5a4 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Thu, 14 Aug 2003 15:33:04 +0000 Subject: [PATCH] handle empty lockfiles --- trunk/ripnews/ripnews.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index be7b4bc..a534889 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -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,13 +260,18 @@ def lock lock = File.open(@config[group]["LOCKFILE"], "r") line = lock.gets lock.close - line.chomp! - psauxw = `ps -auxw` - if /^\S+\s+#{line}\s+/.match(psauxw) - print "Already running, exiting...\n" - exit + if line + line.chomp! + psauxw = `ps -auxw` + if /^\S+\s+#{line}\s+/.match(psauxw) + print "Already running, exiting...\n" + exit + else + print "Stale lock found... removing...\n" + File.unlink(@config[group]["LOCKFILE"]) + end else - print "Stale lock found... removing...\n" + print "Empty lockfile found... removing...\n" File.unlink(@config[group]["LOCKFILE"]) end end