ArticleslgStudy

computer science

Fork bomb

Fork bomb is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fork bomb rather than just read about it. In short: A fork bomb (also called rabbit virus or hydra virus) is a denial-of-service (DoS) attack against a computer where a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation. History Around 1978, an early variant of a fork bomb called Wabbit was reported to run on a System/360.

Fork bomb — main illustration
Fork bomb — illustration

Key takeaways

  • Fork bomb belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fork bomb to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fork bomb from memory before moving on to harder problems.

Reference excerpt

A fork bomb (also called rabbit virus or hydra virus) is a denial-of-service (DoS) attack against a computer where a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation.

History Around 1978, an early variant of a fork bomb called Wabbit was reported to run on a System/360. It may have descended from a similar attack called RABBITS reported from 1969 on a Burroughs 5500 at the University of Washington. Since 2011, Linux has a default nproc limit that can be listed with ulimit -u to mitigate fork bombs and related issues.

Implementation

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 new copies of itself. In Unix-like operating systems, fork bombs are generally written to use the fork system call. As forked processes are also copies of the first program, once they resume execution from the next address at the frame pointer, they continue forking endlessly within their own copy of the same infinite loop. This has the effect of causing an exponential growth in processes. As modern Unix systems generally use a copy-on-write resource management technique when forking new processes, a fork bomb generally will not saturate such a system's memory. Microsoft Windows operating systems do not have an equivalent functionality to the Unix fork system call; a fork bomb on such an operating system must therefore create a new process instead of forking from an existing one, such as with batch echo %0^|%0 > $_.cmd & $_. In this batch script, %0|%0 is written to $_.cmd, which is then executed by & $_. A classic example of a fork bomb is one written in Unix shell :(){ :|:& };:, dating back to at least 1999, which can be more easily understood as

In it, a function is defined (fork()) as calling itself (fork), then piping (|) its result into itself, all in a background job (&). The code using a colon : as the function name is not valid in a shell as defined by POSIX, which only permits alphanumeric characters and underscores in function names. However, its usage is allowed in GNU Bash as an extension. The traditional C implementation (using the POSIX headers) is:

This repeatedly calls the fork() function, duplicating the current process, in the header <unistd.h>. Various forms of such a fork bomb have been created.

Prevention As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own. On Linux, this can be achieved by using the ulimit utility; for example, the command ulimit -u 30 would limit the affected user to a maximum of thirty owned processes. On PAM-enabled systems, this limit can also be set in /etc/security/limits.conf, and on *BSD, the system administrator can put limits in /etc/login.conf. Modern Linux systems also allow finer-grained fork bomb prevention through cgroups and process number (PID) controllers.

See also Billion laughs attack Deadlock (computer science) Logic bomb ReDoS Time bomb (software) Zip bomb

References

External links Fork bomb examples on GitHub

Illustrations

Fork bomb: The concept behind a fork bomb – the processes continually replicate themselves, potentially causing a denial of service
The concept behind a fork bomb – the processes continually replicate themselves, potentially causing a denial of service
Fork bomb: Demonstration of a fork bomb in Arch Linux
Demonstration of a fork bomb in Arch Linux

Worked examples

Example 1 — a first encounter with Fork bomb

Start with the simplest possible case. Write down what Fork bomb claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fork bomb before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fork bomb ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fork bomb

In research
Fork bomb appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fork bomb in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fork bomb is common in secondary-school and first-year university syllabi. It links to neighbouring topics Denial-of-service attacks, Process (computing), so understanding it makes those chapters shorter.
In everyday life
Look for Fork bomb outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Fork bomb” →

How to study Fork bomb in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fork bomb means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fork bomb out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fork bomb in simple terms?

A fork bomb (also called rabbit virus or hydra virus) is a denial-of-service (DoS) attack against a computer where a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation. History Around 1978, an early variant of…

Why does Fork bomb matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fork bomb?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fork bomb.

Tags

  • Denial-of-service attacks
  • Process (computing)

Keep exploring