191145692 发表于 2017-4-21 11:10:41

python 进程

import time
import os, sys

def handleChild(chNum):
  time.sleep(20)
  print "Hi, I'm child ", chNum
  os._exit(0)

if __name__ == '__main__':
  for i in range(5):
    childPid = os.fork()
    if childPid == 0:
      handleChild(i)
    else:
      print "Hi, I'm father, fork ", i
  time.sleep(40)
 
页: [1]
查看完整版本: python 进程