Skip to content

Instantly share code, notes, and snippets.

Created March 12, 2014 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e32db6a5bc86bb2918a9 to your computer and use it in GitHub Desktop.
Save anonymous/e32db6a5bc86bb2918a9 to your computer and use it in GitHub Desktop.
import os
zerofd = os.open('/dev/zero', os.O_RDONLY)
nullfd = os.open('/dev/null', os.O_WRONLY)
# Close the stdthings and reassociate them with a non terminal
os.dup2(zerofd, 0)
os.dup2(nullfd, 1)
os.dup2(nullfd, 2)
#/usr/local/bin/marconi-server
# Detach process context
try:
pid = os.fork()
if pid > 0:
os._exit(0)
except OSError, ex:
os._exit(1)
try:
pid = os.fork()
if pid > 0:
os._exit(0)
except OSError, ex:
os._exit(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment