0

Possible Duplicate:
How does this bash fork bomb work?

Today one of my friend told me a funny thing, that this such command cause system halted:

:() { :|:& }; :

But, I just don't understand how does this command work and cause such a disaster. Any one comes up with this thing?

Thanks,

Xi

Community
  • 1
  • 1
Xi Duan
  • 93
  • 1
  • 9

1 Answers1

2

In short,

:() { :|:& }; :
|     |       ` Invoke the function
|     ` Run itself twice, once in a subshell, once for each invocation
` Create a new function called :

Which basically means that for each call of :, two instances of : are created, each of which create two more, etc.

The correct solution is sane ulimits.

richo
  • 8,717
  • 3
  • 29
  • 47