From 06a8ed720fbf9aa31a5d8f093c102239952aa6c0 Mon Sep 17 00:00:00 2001 From: kaliko Date: Fri, 23 Sep 2011 14:32:44 +0200 Subject: [PATCH] better error handling error handling should not rest on fuzzy string matching... --- src/daemon.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/daemon.py b/src/daemon.py index 9bb945f..2251f18 100644 --- a/src/daemon.py +++ b/src/daemon.py @@ -20,7 +20,7 @@ class Daemon(object): Usage: subclass the Daemon class and override the run() method """ - version = "0.2" + version = "0.3" def __init__(self, pidfile, stdin='/dev/null', @@ -144,7 +144,7 @@ class Daemon(object): pid = None if not pid: - message = "pidfile %s does not exist. Daemon not running?\n" + message = "pidfile %s does not exist. Is the Daemon running?\n" sys.stderr.write(message % self.pidfile) return # not an error in a restart @@ -153,10 +153,9 @@ class Daemon(object): os.kill(pid, SIGTERM) time.sleep(0.1) except OSError, err: - err = str(err) - if err.find("No such process") > 0: + if err.errno == 3: if os.path.exists(self.pidfile): - message = "Daemon not running? removing pid file %s.\n" + message = "Daemon's not running? removing pid file %s.\n" sys.stderr.write(message % self.pidfile) os.remove(self.pidfile) else: -- 2.39.5