- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
所以我想做以下事情:
设置一个 fork 一堆进程的守护进程。
所以Daemon fork了一堆进程然后 fork 另一串进程
问题是子进程可能需要很长时间才能退出。如果父进程尽管 fork 了子进程还有其他工作要做,我该如何防止僵尸子进程?
父进程(守护进程)做这样的事情:
while(true)
{
SQL QUERY EXECUTED
while(mysql_fetch_array)
{
Fork children
}
}
问题是,如果父进程除了 fork 子进程还需要做其他工作,并且子进程需要很长时间才能退出,我该如何等待子进程退出。
我正在使用系统守护进程 PEAR 函数创建守护进程,并使用 pcntl_fork
函数创建进程。
最佳答案
我不记得我在哪里看到的:
Parent forks child
Waits until child is dead (this won't take long, see ahead)
Goes on
Child does only 2 things:
Forks a grandchild
Exits
Grandchild does whatever work is needed
Exits
诀窍在于,当 Granchild 死亡时,其 parent (您的 child 之一)已经死亡。但是必须通知某人死亡。看来在 Linux 系统中,通知的不是祖 parent ,而是所有人的曾祖 parent 。而且因为该进程知道自己的工作,所以它会定期检查死去的 child ,并且不允许他们变成僵尸。
这是一个带有解释的链接:http://fixunix.com/unix/533215-how-avoid-zombie-processes.html
When a process's parent terminates, the "init" process takes over as its parent. So when the child process exits, the grandchild loses its parent, and is adopted by init. Init always reaps its dead children, so they don't become zombies.
关于php - 在父进程中杀死僵尸子进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8086230/
更新:-[NSIndexPath行]:消息发送到已释放实例0x895fe70 当我在设备上运行我的应用程序并进行分析时,它说: 将一个Objective-C消息发送到地址为0xaa722d0的已释放对
我现在大部分时间都在尝试调试我的 Backbone 多页面应用程序以摆脱“僵尸”,但不幸的是没有成功。在今天之前,我什至没有意识到我有一个僵尸问题。我做错了什么? 这是我的区域经理: var re
我确实读过这篇文章:https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/ 设置一些上下文:文章
调试使用 iPhone SDK 3.x 目标构建的应用程序时是否支持 NSZombiesEnabled? 此外,如果支持的话,我可以在哪里获取支持的可能级别的列表吗? 最佳答案 是的,设备和模拟器都支
我正在尝试了解主干,并且目前正在努力尝试僵尸 View 。我已经阅读了很多有关此问题的堆栈溢出信息,但仍然无法解决。 为了简单起见,我设置了两个需要切换的 View (无数据)。 到目前为止,我所做的
我正在尝试使用 psycopg 和多处理插入和更新几百万行。查看 http://initd.org/psycopg/docs/usage.html#thread-and-process-safety
我的应用程序在 Linux 机器上进入僵尸状态,它无法被杀死并且 gdb 无法附加到它,我无法调试。现在我想知道最后调用的函数或回溯,无论如何我可以得到这个吗?/proc/pid/stat 下是否有我
我将我的程序作为守护进程运行。 父进程只等待子进程,当它意外死亡时,fork并再次等待。 for (; 1;) { if (fork() == 0) break; int sig = 0;
注意:我们使用的是 Backbone 1.0.0 我对 Backbone 比较陌生,并且打算通过前同事编写的一些代码。我不是盲目地复制粘贴东西,而是想了解他是如何做事的,这就是我开始思考处理僵尸 Vi
我的 Backbone Marionette 应用程序出现问题,我的 subview 没有被完全破坏。您如何正确销毁要替换为另一个布局/项目 View 的嵌套布局 View ? 我对 Marionet
我有两个应用程序在一个服务器上运行,它们执行 headless (headless)浏览任务。每次浏览时,Xvfb 进程并没有死,而是变成了僵尸。我可以用以下脚本确认这一点。 require 'hea
我正在尝试使用 Marionet 模块来玩 Backbone。 例如。实现“加载微调器”,正如 David Sulc 在“contact manager”应用程序中所做的那样,Firefox 的“ba
当我尝试使用 Xcode 菜单(Product - Archive)直接存档项目时,效果很好。但是当我尝试从集成菜单 (bot) 执行它时,出现了这个错误: Build operation faile
我有一个从 nib 构建的 MainWindow 类,设置如下: - (void)applicationDidFinishLaunching:(UIApplication *)application
我关注 this answer跟踪我的应用的 EXC_BAD_ACCESS。是的,我有一个僵尸物体。当我试图找出哪一行代码是错误的时,我发现所有负责任的图书馆都是基金会的。 当我尝试这样做时: Whe
我是 iOS 开发的新手,非常感谢您帮助我找出我遇到的错误的根本原因。 我尝试使用 Instruments(即 Allocations-Zombie Profiler)调试错误,但我无法理解所呈现的调
我是一名优秀的程序员,十分优秀!