Mercurial > templog
diff server/utils.py @ 371:7dec59b7eeef
cheap_daemon()
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 26 Jun 2012 21:36:54 +0800 |
parents | 20f7161399a8 |
children | c5ad12670cae |
line wrap: on
line diff
--- a/server/utils.py Tue Jun 26 21:21:51 2012 +0800 +++ b/server/utils.py Tue Jun 26 21:36:54 2012 +0800 @@ -97,3 +97,24 @@ uc += 1 i += 1 return crc + +def cheap_daemon(): + try: + pid = os.fork() + if pid > 0: + sys.exit(0) + except OSError, e: + print>>sys.stderr, "Bad fork()" + sys.exit(1) + + os.setsid() + + try: + pid = os.fork() + if pid > 0: + sys.exit(0) + except OSError, e: + print>>sys.stderr, "Bad fork()" + sys.exit(1) + +