Mercurial > templog
comparison server/utils.py @ 66:c5ad12670cae
dup2 to devnull
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 26 Jun 2012 21:46:08 +0800 |
parents | b09c164debf6 |
children | 51d889ad39a3 |
comparison
equal
deleted
inserted
replaced
65:b09c164debf6 | 66:c5ad12670cae |
---|---|
97 uc += 1 | 97 uc += 1 |
98 i += 1 | 98 i += 1 |
99 return crc | 99 return crc |
100 | 100 |
101 def cheap_daemon(): | 101 def cheap_daemon(): |
102 print "Daemonising." | |
103 sys.stdout.flush() | |
104 sys.stderr.flush() | |
105 out = file('/dev/null', 'a+') | |
106 os.dup2(out.fileno(), sys.stdout.fileno()) | |
107 os.dup2(out.fileno(), sys.stderr.fileno()) | |
108 | |
102 try: | 109 try: |
103 pid = os.fork() | 110 pid = os.fork() |
104 if pid > 0: | 111 if pid > 0: |
105 sys.exit(0) | 112 sys.exit(0) |
106 except OSError, e: | 113 except OSError, e: |