how : ( ) { : | : & } ; : works [duplicate]
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
精彩评论