Why does this linux shell command halt the system? [closed]
Warning: malicious code. Do not try this. It appears here for educational purposes only.
If you type this shell开发者_C百科 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
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.
精彩评论