通过fork产生的进程有以下几个特点:
#!/usr/bin/env python
import os
def child_process():
    print "I am the child process and my PID is : %d" % os.getpid()
    print "teh child is exiting."
def parent_process():
    print "I am the parent process whit PID  :%d" % os.getpid()
    childId = os.fork()
    if childId == 0:
        #在子进程中
        child_process()
    else:
        #在父进程中
        print "inside the parent process"
        print "my child‘s pid is : %d" % childId
    while True:
        pass
parent_process()
子线程结束后,父线程依然在运行,并没有推出。
可以发现通过这种方式创建的进程是覆盖掉了父进程,当子进程结束时,父进程也跟着结束了。
python 系统编程之创建进程 create process
原文地址:http://blog.csdn.net/jeanphorn/article/details/45193019