December 28, 2011 § Leave a comment
I recently learned about fork bombs and I find myself intrigued by the simplicity behind them.
For those who are unfamiliar with them, I quote the Wikipedia article which provides a nice succinct definition:
A fork bomb works by creating a large number of processes very quickly in order to saturate the available space in the list of processes kept by the computer’s operating system. If the process table becomes saturated, no new programs may start until another process terminates.
Here’s the Python example from the article:
import os while True: os.fork()
Pass those three lines to the Python interpreter and you’ll crash your machine. This isn’t even the shortest example – the Windows batch example is five characters (%0|%0). You can even (apparently) create one in HTML and JS which would allow you to lock a computer (independent of OS) just by visiting a website.
I don’t bring this up to suggest that this is something you should do. Far from it in fact. Rather, I find this simplicity quite elegant (this is what intrigues me). With such a limited input, you can lock up an OS. I’ve tried it (using the Python example above) and the results were interesting. The virtual machine I tried this in slowly sucked up the RAM available to it to the point of locking up. When I say lock up, I mean it in the old ‘Windows 98’ style when nothing was responsive.
Moral of the story: simplicity can still beat complex OS design.