Nasty fork() bomb

From: Sudheer (sudheerreddy.p_at_gmail.com)
Date: 02/07/05


Date: 7 Feb 2005 06:34:06 -0800

Hello Everyone,

         I have a program which forks for 5 times. Its children fork 5
times. These children fork five times.... This is done 10 times. The
10th generation just exit. This causes about 5^10 + 5^9 + 5^8 + ... +
5 forks.

          After this the machine freezes for about 30 mins and then
comes to normal state. Conceptually, fork() after creating huge no of
child, fails with ENOMEM/EAGAIN. But even after exiting the machine is
taking long time to come to normal state. Why is this happening? how
can we avoid?

           I am new to unix system progamming! Help me out.

Thanks



Relevant Pages

  • Re: Nasty fork() bomb
    ... > taking long time to come to normal state. ... This means the program will continued to fork, ... most disks will do random IOs in about 10 ... kept growing to contain all the kernel data (lwp stack, proc structure, ...
    (comp.unix.solaris)
  • Nasty fork() bomb
    ... These children fork five times.... ... child, fails with ENOMEM/EAGAIN. ... taking long time to come to normal state. ...
    (comp.unix.solaris)
  • Re: timing a fork
    ... if ($kid) { ... What it does is say that the parent isn't interested in ... Once a parent process has forked it can carry on on its own while the child ... In fact what a call to 'system' does is to fork a child ...
    (perl.beginners)
  • Re: Ruby lacks atfork : The evil that lives in fork...
    ... so that there's no way to ensure mutex to share ... Give the resource to the child. ... fork() in a multi-threaded program. ... multi-threaded I/O libraries, which are almost sure to be invoked ...
    (comp.lang.ruby)
  • Re: EPERM from pthread_mutex_unlock after fork using pthread_atfork()
    ... So, if the fork() creates a copy of the parent, the child should get a copy of the mutex as well. ... it should be locked in the child process and the parent process once the forkprocessing is complete. ...
    (comp.programming.threads)