I tried this experiment on my Linux desktop:
int main()
{
while(1)
fork();
return 0;
}
I ran this program as normal user(not root), i was surprised to find that it brought down my system, it has become unresponsive. I had hoped that due to resource limit exhaustion my process would have been killed,but apparently this is not the case. Any ideas why?
thanks, Sid.
PS: this was my office Linux box on which i was experimenting from home, i hope everything will be okay when i restart it tomorrow ....
You've re-invented a fork bomb.
I think most Linux distributions don't set per-user resource limits by default. You can configure them of course, but you probably haven't.
The machine will be fine after a reboot - unless the CPU usage has caused over-heating problems.
To prevent an ordinary user from spawning too many processes you need to add configuration to /etc/security/limits.conf
You can use ulimit
to set limits that would apply to your current session if you think you're going to run a program that might start too many processes or use up too much of other resources.
you can find stuffs about that on wikipedia.
Most likely, your system administrator didn't set up the user limits. If no user limits are set, then they can't protect anyone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With