开发者

Why does this linux shell command halt the system? [closed]

开发者 https://www.devze.com 2022-12-14 03:10 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 13 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消