Here a function is called recursively and each call forks or creates two child processes which run as background process and cannot be auto killed. This way a large number of processes gets created eating away the system resources and brings the system to halt or crash.
Wiki: “the fork bomb is a form of denial-of-service attack against a computer system which makes use of the fork operation (or equivalent functionality) whereby a running process can create another running process. Fork bombs typically do not spread as worms or viruses; to incapacitate a system, they rely on the (generally valid) assumption that the number of programs and processes which may execute simultaneously on a computer has a limit.”
Understanding fork bomb code
Here is more human readable code:
Well a various other forms of the fork bomb, for other operating systems can be found here.
If you wanna try it out in your machine make sure to go through the prevention techniques mentioned here. Well in most cases a system restart/reboot solves the problem.