POSIX Process Calls # fork -- create a (duplicate) process if os.fork() == 0: print "in child" else: print "in parent" # exec -- overlay the process with another executable os.execl("/bin/more", "more", "foo.txt") # note: no 0 terminator os.execvp(sys.argv[0], sys.argv) # sleep -- put process to sleep for specified time time.sleep(n) # exit -- terminate process sys.exit(0) # wait -- wait for termination of child pid, status = wait() # no arguments, returns a pair of values print "Returned status:", status/256 # getpid -- return process id myId = os.getpid()