summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Daemon.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/Daemon.py b/src/lib/Daemon.py
index edb8bc40e..bdce2c179 100644
--- a/src/lib/Daemon.py
+++ b/src/lib/Daemon.py
@@ -20,7 +20,7 @@ def daemonize(filename):
raise SystemExit, 1
except OSError:
pidfile.close()
- except IOError:
+ except (IOError, ValueError):
# pid file doesn't
pass
@@ -30,9 +30,12 @@ def daemonize(filename):
os.setsid() # Create new session
pid = os.fork()
if pid != 0:
- pidfile = open(filename, "w")
- pidfile.write("%i" % pid)
- pidfile.close()
+ try:
+ pidfile = open(filename, "w")
+ pidfile.write("%i" % pid)
+ pidfile.close()
+ except:
+ print "Failed to write pid file %s" % filename
os._exit(0)
os.chdir("/")
os.umask(0)