开发者

how : ( ) { : | : & } ; : works [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How does this bash开发者_运维问答 fork bomb work?

Hi,

quick questions.

How does this shell command works and why it gains the cpu usage up to 100% ?

: ( ) { : | : & } ; :


Here is the short explanation coursey of wikipedia (http://en.wikipedia.org/wiki/Fork_bomb):

:()      # define ':' -- whenever we say ':', do this:
{        # beginning of what to do when we say ':'
    :    # load another copy of the ':' function into memory...
    |    # ...and pipe its output to...
    :    # ...another copy of ':' function, which has to be loaded into memory
         # (therefore, ':|:' simply gets two copies of ':' loaded whenever ':' is called)
    &    # disown the functions -- if the first ':' is killed,
         #     all of the functions that it has started should NOT be auto-killed
}        # end of what to do when we say ':'
;        # Having defined ':', we should now...
:        # ...call ':', initiating a chain-reaction: each ':' will start two more.

Basically a recursive function, with each recusrive call resulting in two more processes. So the number of processes grows exponentially.


This is a Fork Bomb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜