读书人

如何屏蔽fork炸弹

发布时间: 2013-11-29 13:49:33 作者: rapoo

怎么屏蔽fork炸弹
while(1)
{
fork();
}
这样的

我用ulimit 限制进程数 虽然不会死机了 但是当前控制台没办法在执行指令了
会显示
bash: fork: retry: 没有子进程

有没有这个API 最好在程序里面C语言实现

[解决办法]
As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own. On Linux, this can be achieved by using the ulimit utility; for example, the command ulimit -u 30 would limit the affected user to a maximum of thirty owned processes.[8] On PAM-enabled systems, this limit can also be set in /etc/security/limits.conf,[9] and on FreeBSD, the system administrator can put limits in /etc/login.conf.[10]

http://en.wikipedia.org/wiki/Fork_bomb#Prevention

读书人网 >UNIXLINUX

热点推荐