Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
example for double fork
import os
import sys
print 'pid,pgid,sid', os.getpid(), os.getpgid(0), os.getsid(0)
pid = os.fork()
if pid > 0:
sys.exit(0)
print 'pid,pgid,sid', os.getpid(), os.getpgid(0), os.getsid(0)
os.setsid()
print 'pid,pgid,sid', os.getpid(), os.getpgid(0), os.getsid(0)
pid = os.fork()
if pid > 0:
sys.exit(0)
print 'pid,pgid,sid', os.getpid(), os.getpgid(0), os.getsid(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment