According to Wikipedia, the following is a very elegant bash fork bomb:
:(){ :|:& };:
How does it work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Breaking it down, there are three big pieces:
Inside the body, the function is invoked twice and the pipeline is backgrounded; each successive invocation on the processes spawns even more calls to “:”. This leads rapidly to an explosive consumption in system resources, grinding things to a halt.
Note that invoking it once, infinitely recursing, wouldn’t be good enough, since that would just lead to a stack overflow on the original process, which is messy but can be dealt with.
A more human-friendly version looks like this:
Edit: William’s comment below was a better wording of what I said above, so I’ve edited to incorporate that suggestion.