首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

如何屏蔽fork炸弹

2013-11-29 
怎么屏蔽fork炸弹while(1){ fork()}这样的我用ulimit 限制进程数 虽然不会死机了 但是当前控制台没办法在

怎么屏蔽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

热点排行