Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After running a bash fork bomb which made my webserver down, I think I should be more careful even not under root.I thought it would be totally fine while I'm not under root.So I ignored the warning and ran the bash fork bomb which is :() { :|:& }; : .(Please don't run it if u don't understand this code cuz it will make you system down).And I think I need a list of common ways those could cause a sever shutting down unexpectly even not under root.

Any suggestion would be appreciated.

Regards `

share|improve this question

migrated from stackoverflow.com Mar 18 '10 at 17:49

This question came from our site for professional and enthusiast programmers.

closed as not a real question by Dennis Williamson, Zoredache, Zypher, John Gardeniers, splattne Mar 19 '10 at 6:24

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

9  
Clearly, now, we have to add "Letting you manage it" to the list of ways to shut a server down unexpectedly. :-) –  tvanfosson Mar 18 '10 at 16:10
    
I will remove it soon:) –  SpawnCxy Mar 18 '10 at 16:15
add comment

3 Answers

up vote 1 down vote accepted

If linux runs out of memory resources then it will invoke the 'out of memory' killer.

This will pick (at random) a process to terminate to free up resources. If you system is invoking the oom killer then it really is out of resources, it usual kills processes as a last resort.

This blog post has a good explanation of it

http://prefetch.net/blog/index.php/2009/09/30/how-the-linux-oom-killer-works/

in your case, I think the OOM killer killed your web server process.

You can stop things like fork bombs by setting per process limits.

However, you can just avoid typing in commands that will harm your system into a live server.

That's what virtual machines are for! ;-)

share|improve this answer
    
The "you can stop things like fork bombs by setting per process limits" is the only relevant part of this answer. The rest is irrelevant and misleading in the case of a fork bomb. –  Jakob Borg Mar 20 '10 at 16:56
    
true, true. ulimit -u 128 will do the trick. –  The Unix Janitor Mar 20 '10 at 21:01
add comment

You probably used up your RAM while running the fork bomb and then the webserver tried to allocate some memory. As no memory was available malloc() or alike returned a NULL-pointer which wasn't checked correctly in the code resulting in trying to read/write a memory block the program had no access to. Therefore the OS Kernel killed the program.

When a webserver or any other service shuts down unexpectedly its most commonly a bug in the software. Either used via remote to use a security hole or locally as in your case.

share|improve this answer
1  
Do you not get how a "fork bomb" works? See en.wikipedia.org/wiki/Fork_bomb. Running a program out of memory generally won't bring down the system -- running the kernel out of resources or corrupting kernel data structures, now that's how to crash a system (or at least bring it to its knees). –  tvanfosson Mar 18 '10 at 16:31
    
you should always check for error's on every system call that you make, it's just good practise. Just because your asking for resources doesn't mean your going to them! –  The Unix Janitor Mar 18 '10 at 22:28
add comment

A large enough tar bomb may do the trick. Though that's generally more malicious than user error.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.