Don’t try this as root

Contexts of a tiny script that you should never run:

cp $0 $$ # Make a copy of yourself
sh $$ & # Run the copy in the background
sh $0 & # Rerun a new version of yourself in the background

This will probably take over your server or at least use up all of the filesystem pointers in its filesytem. In a minute or so you would have thousands of these running and doubling each generation.

This does demonstrate an interesting version of ‘the game of life’. If the copy (cp) could be a little less reliable and the whole thing could work in a few messed up ways, this could actually evolve into some other different tiny script.

Self-reference is always fun times.

3 thoughts on “Don’t try this as root

  1. That’s an interesting take on the fork bomb. It shouldn’t hit the CPU/RAM as quickly, but will also hit I/O and filesystem load.

    If you filled the filesystem, the bomb might terminate early.

    You can do a proper fork bomb in a POSIX shell with:

    :(){ :|:& };:

    In lots of other languages:
    http://en.wikipedia.org/wiki/Fork_bomb

  2. I have never noticed the link color and I can always see my links. I have decided to change to this skin, although it is a little too subtle about how to show comments.

Leave a Reply

Your email address will not be published. Required fields are marked *