In reading the Wikipedia page on the topic I generally follow what's going on with the following code:

:(){ :|:& };:

excerpt of description

The following fork bomb was presented as art in 2002;56 its exact origin is unknown, but it existed on Usenet prior to 2002. The bomb is executed by pasting the following 13 characters into a UNIX shell such as bash or zsh. It operates by defining a function called ':', which calls itself twice, once in the foreground and once in the background.

However the last bit isn't entirely clear to me. I see the function definition:

:(){ ... }

But what else is going on? Also do other shells such as ksh, csh, and tcsh also suffer the same fate of being able to construct something similar?

  • 2
    This one pops up quite often on stack exchange, a good answer is here: stackoverflow.com/questions/991142/…
    – Drav Sloan
    Commented Aug 31, 2013 at 2:27
  • @DravSloan - I was attempting to create some of that content here, my question is a bit loaded in that way 8-).
    – slm
    Commented Aug 31, 2013 at 2:30
  • You may want to add the obligatory "For the Love of God don't run this on a production machine, or if you want to continue using the machine you run it on!!" message :)
    – Drav Sloan
    Commented Aug 31, 2013 at 2:34
  • 1
    @MartinSchröder - you understand that this question was what lead that question to get asked? 8-). I asked this on a friday night to get something going and then the other question came in an hour or 2 afterwards.
    – slm
    Commented Sep 5, 2013 at 20:53
  • 1
    @MartinSchröder - it's probably best to leave them as separate, they're slightly different. This is asking for a whole detailed view of how fork bombs work, that other one was asking for specifics about the mechanism behind how the system is forking within a fork bomb. I know it might seem confusing b/c they are related but they are different (IMO - obviously). I even answered the other Q and tried to show the mechanism under the hood that's driving the forking, and I did not flag it as a dup.
    – slm
    Commented Sep 5, 2013 at 21:45

1 Answer 1


This fork bomb always reminds me of the something an AI programming teacher said on one of the first lessons I attended "To understand recursion, first you must understand recursion".

At it's core, this bomb is a recursive function. In essence, you create a function, which calls itself, which calls itself, which calls itself.... until system resources are consumed. In this specific instance, the recursion is amplified by the use of piping the function to itself AND backgrounding it.

I've seen this answered over on StackOverflow, and I think the example given there illustrates it best, just because it's easier to see what it does at a glance (stolen from the link above...)

☃(){ ☃|☃& };☃

Define the bug function ☃() { ... }, the body of which calls itself (the bug function), piping the output to itself (the bug function) ☃|☃, and background the result &. Then, after the function is defined, actually call the bug function, ; ☃.

I note that at least on my Arch VM, the need to background the process is not a requirement to have the same end result, to consume all available process space and render the host b0rked. Actually now I've said that it seems to sometimes terminate the run away process and after a screenful of -bash: fork: Resource temporarily unavailable it will stop with a Terminated (and journalctl shows bash core dumping).

To answer your question about csh/tcsh, neither of those shells support functions, you can only alias. So for those shells you'd have to write a shell script which calls itself recursively.

zsh seems to suffer the same fate (with the same code), does not core dump and causes Arch to give Out of memory: Kill process 216 (zsh) score 0 or sacrifice child., but it still continues to fork. After a while it then states Killed process 162 (systemd-logind) ... (and still continues to have a forking zsh).

Arch doesn't seem to have a pacman version of ksh, so I had to try it on debian instead. ksh objects to : as a function name, but using something - say b() instead seems to have the desired result.

  • What are those characters? I know they're bugs but how did you make them?
    – slm
    Commented Aug 31, 2013 at 2:46
  • 10
    While at a small font size it does look like a bug you'll find that it is in fact a snowman. That would be unicode character U+2603 which can be displayed in html by entering & # x 2603 without the spaces.
    – sambler
    Commented Aug 31, 2013 at 3:14
  • 2
    Apparently under Linux a fair number of Gnome related apps and Firefox support the Ctrl+Shift+u+<hex> where hex is the hex code of the unicode character you want to display. A list of viewable unicode can be found at: fileformat.info/info/unicode/utf8test.htm (most of the odd ones are in the "miscellaneous" sections). Windows should checkout superuser.com/questions/47420/…, and I personally use the tool mentioned in the link unicodeinput.exe or cut and paste via my browser. You can always use html sequences as suggested by sambler.
    – Drav Sloan
    Commented Aug 31, 2013 at 3:55
  • 1
    Wiki also has a list of unicode characters: en.wikipedia.org/wiki/List_of_Unicode_characters
    – Drav Sloan
    Commented Aug 31, 2013 at 4:32
  • I liked the snowman bug, the one you are using here is not displayed on my system, 🐛 appears like a box with hex numbers in it.
    – terdon
    Commented Aug 31, 2013 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .