changeset 66:c5ad12670cae

dup2 to devnull
author Matt Johnston <matt@ucc.asn.au>
date Tue, 26 Jun 2012 21:46:08 +0800
parents b09c164debf6
children a26da94f3164
files server/ts.py server/utils.py
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/server/ts.py	Tue Jun 26 21:36:54 2012 +0800
+++ b/server/ts.py	Tue Jun 26 21:46:08 2012 +0800
@@ -25,6 +25,7 @@
 import config
 
 from utils import monotonic_time, retry, readline, crc16
+import utils
 
 lightblue = None
 try:
--- a/server/utils.py	Tue Jun 26 21:36:54 2012 +0800
+++ b/server/utils.py	Tue Jun 26 21:46:08 2012 +0800
@@ -99,6 +99,13 @@
     return crc
 
 def cheap_daemon():
+    print "Daemonising."
+    sys.stdout.flush()
+    sys.stderr.flush()
+    out = file('/dev/null', 'a+')
+    os.dup2(out.fileno(), sys.stdout.fileno())
+    os.dup2(out.fileno(), sys.stderr.fileno())
+
     try:
         pid = os.fork()
         if pid > 0: