Process Creation and Destruction

fork-exec-wait

     os.fork()                         # Create a child process.
     os.execv(path,args)               # Execute a process
     os.execve(path, args, env)
     os.execvp(path, args)             # Execute process, use default path
     os.execvpe(path,args, env)
     os.wait([pid)]                    # Wait for child process
     os.waitpid(pid,options)           # Wait for change in state of child
     os.system(command)                # Execute a system command
     os._exit(n)                       # Exit immediately with status n.

Canonical Example

     import os
     pid = os.fork()         # Create child
     if pid == 0:
         # Child process
         os.execvp("ls", ["ls","-l"])
     else:
         os.wait()           # Wait for child 
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 53
July 17, 2000, beazley@cs.uchicago.edu
>>>