On my computer, this pushes one core to ~60%, eats ~40MB of memory over the course of about a minute and then segfaults.
I did make one small change to the condition which would mean that it would bail out if available memory got too low, but 40MB barely even registered so it was basically true the whole time. In retrospect, I probably should have been monitoring process count instead (or done both), but I guess I got away with it.
As OP says, you need to create subprocesses with & to cause real problems.
*Bash 5.2.15 / LMDE6 / who knows what other factors. Try these things at your own risk. Or better, just don’t.
The good old fork bomb.
function f while true; do f & doneedit: forgot the ampersand - the actual fork
not sure but for it to be a fork bomb you need something like
&in ur pseudo code to go on to the next callrn the first call of
fwithin the loop never completes so the second doesn’t happen. So this is “just” infinite recursionpls don’t scream at me should i be wrong.
edit: i meant “completes” not “compiles”
No you’re right.
I also attempted to write pseudocode; not sure bash will even do this without curly brackets.
On my computer, this pushes one core to ~60%, eats ~40MB of memory over the course of about a minute and then segfaults.
I did make one small change to the condition which would mean that it would bail out if available memory got too low, but 40MB barely even registered so it was basically true the whole time. In retrospect, I probably should have been monitoring process count instead (or done both), but I guess I got away with it.
As OP says, you need to create subprocesses with
&to cause real problems.*Bash 5.2.15 / LMDE6 / who knows what other factors. Try these things at your own risk. Or better, just don’t.