os.fork - Serbipunk/notes GitHub Wiki

import os
import time

print '****current pid %d****'%os.getpid()

pid = os.fork()
if pid == 0:
    # We are in the child process.
    print "%d (child) just was created by %d." % (os.getpid(), os.getppid())
else:
    # We are in the parent process.
    print "%d (parent) just created %d." % (os.getpid(), pid)