5 ms·
I believe either my brother or someone he knew once wrote a program that spawned lots of child processes. He did that to test a scheduler or something like that
by mcv 3y ago
I believe either my brother or someone he knew once wrote a program that spawned lots of child processes. He did that to test a scheduler or something like that, but it got a bit out of hand and swamped a major server in endless processes. Admins weren't pleased. But also not too upset, because they approved of students experimenting. We had pretty cool admins.
- microtonal 3y agoA fork bomb. In shell: :(){ :|:& };:
- doetoe 3y agoCould you explain how this works?
- system33- 3y agoA function called ':' is defined. In its body, it calls itself twice at the same time (':|:') (piping the output of the first call into the second, which doesn't do anything useful) and sends these calls to the background ('&'). After function ':' is finished being defined, it is called. The first call spawns two clones. Each of those spawn two more. Etc.
- doetoe 3y agoGreat, thanks!
- xav0989 3y ago:() defines a new function called : { :|:& } is the body of the function, where we call the : function recursively, piping (|) its output to another call to :, then backgrounding the whole thing (&) ; indicate the end of a statement and the start of a new one : and finally the last : calls the function we defined to start the chain Essentially each time the function is ran, it creates 2 new copies of itself, which each create 2 copies of themselves, etc. until your OS stops responding and crashes. Nowadays many shells recognize this particular fork bomb and refuse to execute it
- _flux 3y ago> Nowadays many shells recognize this particular fork bomb and refuse to execute it Nice try! Though, do they really? I quickly checked if I would find something like this in bash, zsh or tcsh and failed, but I only spent a minute or so..
- sva_ 3y agoWell I can experimentally confirm that it works on zsh/alacritty ;)
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- mcguire 3y agoOh, lord. The sheer number of fork-bombs launched by the students in the systems programming course the week the professor introduced fork()....