def createDaemon():
    """Detach a process from the controlling terminal and run it in the
   background as a daemon.
   """
try:
    pid = os.fork()
except OSError as e:
    raise Exception('%s [%d]' % (e.strerror, e.errno))
if pid == 0:
    os.setsid()
try:
    pid = os.fork()
except OSError as e:
    pass
Bring the current Python program to background