1

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% ?

: ( ) { : | : & } ; :
Community
  • 1
  • 1
CarlJ
  • 9,461
  • 3
  • 33
  • 47

2 Answers2

6

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.

Karthik Ramachandran
  • 11,925
  • 10
  • 45
  • 53
2

This is a Fork Bomb

Roman Cheplyaka
  • 37,738
  • 7
  • 72
  • 121