为什么fork()两次 [英] Why fork() twice

查看:174
本文介绍了为什么fork()两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Nagios允许我配置 child_processes_fork_twice =< 0/1>

Nagios lets me configure child_processes_fork_twice=<0/1>.

文档


此选项确定Nagios在执行主机和服务检查时是否会fork()子进程两次。默认情况下,Nagios fork()为两次。但是,如果use_large_installation_tweaks选项被启用,它将只有fork()一次。

This option determines whether or not Nagios will fork() child processes twice when it executes host and service checks. By default, Nagios fork()s twice. However, if the use_large_installation_tweaks option is enabled, it will only fork() once.

据我所知 fork()将产生一个新的子进程。

As far as I know fork() will spawn a new child process. Why would I want to do that twice?

推荐答案

在Linux中,守护进程通常由在分娩后中途退出两次。这具有对孙子过程的孤儿的影响。因此,如果操作系统终止,它将成为清理后的责任。原因与所谓的僵尸过程有关,因为他们的父母(通常负责清理)也已经死亡,因此继续生活和消耗资源。

In Linux, a daemon is typically created by forking twice with the intermediate process exiting after forking the grandchild. This has the effect of orphaning the grandchild process. As a result, it becomes the responsibility of the OS to clean up after it if it terminates. The reason has to do with what are known as zombie processes which continue to live and consume resources after exiting because their parent, who'd normally be responsible for the cleaning up, has also died.

这篇关于为什么fork()两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆