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
|