Hacker News new | ask | show | jobs
by reilly3000 2686 days ago
Welp, I still don't know what :(){ :|:& };: exactly does, but it sure borked my WSL. Error: 0x80070040 after forking too many processes.

I know comment moderation sucks, but it would be great to have some kind of wiki/comment system/human generated notes on popular commands.

7 comments

It's a classic "fork bomb": https://en.m.wikipedia.org/wiki/Fork_bomb
Not quite wiki (you have to create your own notes) but you may find this utility helpful: https://github.com/sinclairtarget/um
You define a function named :, which calls iself and goes in the background. Then you call : at the end and start the neverending chain of :-calls till your memory bleeds.
Not really: the function `:` calls itself and _pipes_ into itself.

The difference is - from what I can deduce - that if it were to only call itself, there would be up to 2 `:` processes running at a time, while the bash call stack would grow indefinitely. Using all your RAM but not an actual fork bomb.

Adding the pipe makes the number of `:` processes grow exponentially, and very quickly you reach the limit of 16384 active processes (PIDs, actually) on a Linux box.

You have gazed upon the smileyface of doom.

Also, that does sound great.

It defines a function : that launches two copies of itself in the background. Then it calls that function.

    bomb() { bomb | bomb & }; bomb
Its also known as a fork bomb! I have one tattooed on my arm.
Interesting that WSL does not take the entire host to doom.
Oh it did. I have 32 cores, but still managed to have so many threads running that Task Manager itself went Not Reaponding.