The fork bomb is a single line of code that can shut down a computer.
It’s also known as a wabbit – from, I assume, Looney Tunes – and it is elegant in its simplicity. The fork does just one thing: it makes copies of itself, much like the computer worm. Those copies make copies, growing exponentially and overwhelming the system. They keep going until the computer grinds to a standstill, doing nothing but running thousands of copies of copies of copies.
Here’s an example in Bash:
bomb(){
bomb | bomb &
}
bomb
(If you don’t read Bash, the first line creates a function called “bomb,” the second line defines the function as running itself and creating a copy; the last line sets the whole thing running.)
That example uses “bomb” as the function name, but you could make it even smaller by replacing it with “:” – leaving a fork bomb that looks like a complicated emoji:
:(){ :|:& };:
Fortunately most modern systems have ways to prevent such a simple attack from overwhelming the whole system.