好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

fork python

fork python

#!/usr/bin/env  python

  

import  os  

  

def  my_fork():  

    child_pid  =  os.fork()  

    if  child_pid  ==  0:  

        print  "Child  Process:  PID#  %s"  %  os.getpid()  

    else:  

        print  "Parent  Process:  PID#  %s"  %  os.getpid()  

  

if  __name__  ==  "__main__":  

    my_fork()  

首先这里是有两个进程在执行,父子关系,这样就好理解了,先有父才有子

查看更多关于fork python的详细内容...

  阅读:44次