当前位置: 技术问答>linux和unix
你懂吗
来源: 互联网 发布时间:2017-01-16
本文导语: while(1) { fork(); } | > #include > main(){while(1) fork;} That is the most destructive code I know of for UNIX.. A fork bomb.. > Don't try it on X; I did and was not please with having to run fsck manually > to...
while(1)
{
fork();
}
{
fork();
}
|
> #include
> main(){while(1) fork;}
That is the most destructive code I know of for UNIX.. A fork bomb..
> Don't try it on X; I did and was not please with having to run fsck manually
> to clean up the mess.
Do not try it anywhere... It makes your system crash, and it has no time
to sync the drive.. It will suck the memory in 15 seconds flat, and data
that should be written will not make it to the drives.
> Shouldn't the kernel have some protection against this and/or any user
> hogging swap space?
EVERY UNIX kernel out there (sorry "Linux-Is-Not-UNIX" people, but Linux
is close enough to UNIX to crash like it.) is vounerable (sp?) to fork
bombs. If someone could some how (seems impossible) implement a routine
that would restrict the number of forks possible, (would also slow the
system probably) then Linux would have a feature no other UNIX OS has.
不过还有一点儿,不断fork,会不断地平分时间片……最后会怎样呢?
> main(){while(1) fork;}
That is the most destructive code I know of for UNIX.. A fork bomb..
> Don't try it on X; I did and was not please with having to run fsck manually
> to clean up the mess.
Do not try it anywhere... It makes your system crash, and it has no time
to sync the drive.. It will suck the memory in 15 seconds flat, and data
that should be written will not make it to the drives.
> Shouldn't the kernel have some protection against this and/or any user
> hogging swap space?
EVERY UNIX kernel out there (sorry "Linux-Is-Not-UNIX" people, but Linux
is close enough to UNIX to crash like it.) is vounerable (sp?) to fork
bombs. If someone could some how (seems impossible) implement a routine
that would restrict the number of forks possible, (would also slow the
system probably) then Linux would have a feature no other UNIX OS has.
不过还有一点儿,不断fork,会不断地平分时间片……最后会怎样呢?
|
递归fork么,父亲有一堆孩子,每个孩子又有一堆孩子,这是一个N*N*N的问题。
|
跑一下就知道,呵呵
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。