5

I have read the other questions about its functionality -- that fork bombs operate both by consuming CPU time in the process of forking, and by saturating the operating system's process table.

A basic implementation of a fork bomb is an infinite loop that repeatedly launches the same processes.

But I really want to know: what's the story of this command? why this :(){ :|:& };: and not another one?

2 Answers 2

16

It is not something new. It dates way back to 1970's when it got introduced.

Quoting from here,

One of the earliest accounts of a fork bomb was at the University of Washington on a Burroughs 5500 in 1969. It is described as a "hack" named RABBITS that would make two copies of itself when it was run, and these two would generate two more copies each, and the copies would continue making more copies until memory was full, causing a system crash. Q The Misanthrope wrote a Rabbit-like program using BASIC in 1972 while in grade 7. Jerry Leichter of Yale University describes hearing of programs similar to rabbits or fork bombs at his Alma Mater of Princeton and says given his graduation date, they must be from 1973 or earlier. An account dating to 1974 describes a program actually named "rabbit" running on an IBM 360 system at a large firm and a young employee who was discharged for running it.

So the :(){ :|:& };: is just a way of implementing the fork bomb in shell. If you take some other programming language, you could implement in those languages as well. For instance, in python you could implement the fork bomb as,

 import os
 while True: 
     os.fork()

More ways of implementing the fork bomb in different languages can be found from the wikipedia link.

If you want to understand the syntax, it is pretty simple. A normal function in shell would look like,

foo(){
    # function code goes here
}

The fork() bomb is defined as follows:

:(){
 :|:&
};:

:|: - Next it will call itself using programming technique called recursion and pipes the output to another call of the function :. The worst part is function get called two times to bomb your system.

& - Puts the function call in the background so child cannot die at all and start eating system resources.

; - Terminate the function definition

: - Call (run) the function aka set the fork() bomb.

Here is more human readable code:

bomb() {
 bomb | bomb &
}; bomb

References

http://www.cyberciti.biz/faq/understanding-bash-fork-bomb/

0
2

Its formulation as a sequence of smile-like character was popularized by an Italian hacker-artist: https://jaromil.dyne.org/journal/forkbomb.html

After all, the same fork bomb could be written in a more understandable way:

bomb() {
 bomb | bomb &
}
bomb

However, Jaromil wanted to encode a virus in a poetic way, citing him:

In considering a source code as literature, I am depicting viruses as though they were the sort of poems written by Verlaine, Rimbaud et al., against those selling the net as a safe area for straight society. [...] Viruses are a political symptom of a community which continues to be extremely vast and banning them is not the solution to the problems deriving therefrom. The same holds true for anonymity and hacking.

It must be noted that Jaromil did not invent the bomb, but proposed it as an anonymous art work.

1
  • that's Interesting!
    – Mazdak
    Sep 11, 2022 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .