views:

169

answers:

1

Warning: malicious code. Do not try this. It appears here for educational purposes only.

If you type this shell snippet in your shell, your system seems stopped, do you know why?

:() { :|:& }; :      #

the only thing you can do is reboot your system.. Can you gimme some explanation

+17  A: 

It's an endless recursion. You're defining a function called ':', which calls itself and pipes its own output to yet another instance of itself, and round it goes. The pipeline is also forked off and executed in the background, thanks to the '&'. That last ':' actually initiates the call (the semicolon just ends the previous command, which was defining the function, a newline would do here as well).

To make it more clear, this is what it does

foo() {
  foo | foo &
}
foo

It's pretty much a fork-bomb, combined with a massive use of IPC resources.

roe
+1 for question and answer; the question closers on here seem a bit over-zealous sometimes.
gareth_bowles