hot-restarter.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:ambassador 作者: datawire 项目源码 文件源码
def fork_and_exec():
  """ This routine forks and execs a new child process and keeps track of its PID. Before we fork,
      set the current restart epoch in an env variable that processes can read if they care. """

  global restart_epoch
  os.environ['RESTART_EPOCH'] = str(restart_epoch)
  print ("forking and execing new child process at epoch {}".format(restart_epoch))
  restart_epoch += 1

  child_pid = os.fork()
  if child_pid == 0:
    # Child process
    os.execl(sys.argv[1], sys.argv[1])
  else:
    # Parent process
    print ("forked new child process with PID={}".format(child_pid))
    pid_list.append(child_pid)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号