Linux Fork Bomb
:() {: |: &}: is a bash function, known as fork Bomb, is a Linux system that denies service attacks. If you are curious to carry out this command, then quickly restart the system!
Command parsing
:(){ : | : &};:
- : Here is a function name, which we define, and execute it later.
- :|:&: The output of the function is passed through the pipeline to another colon function as input and executed in the background.
- { }; Identifies the content inside as a function body.
- last one: the function executes once the definition is complete.
Principle Analysis
- The first thing to note is that it is a shell built-in command, so the above code is only likely to produce a fork bomb in bash, because in some other shells, built-in commands have precedence over functions, so execute :always execute built-in commands. (: is an empty command, while true is equivalent to while :, commonly used as a placeholder)
- Let's take a look at the main body of the function :|:&, when using a pipeline, two processes start executing at the same time.
- So when executing a:function, two new processes are generated, and then an original process exits, so that the recursion continues, resulting in an infinite recursion. In line with this growth model, its growth trend is about < Span class= "Mrow" id= "mathjax-span-2" > 2 n Span style= "Display:inline-block; width:0px; Height:2.349em; " > 。
Summarize
There are many more commands for this trap in Linux, which is why I like Linux and is full of exploration.
Feedback and Suggestions
- Weibo: @AnSwEr not the answer
- Github:answerywj
- Blog: answer is not the answer column
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux Fork Bomb parsing--linux Fork Bomb