Re: Fork bomb.

Andrew E. Mileski (aem@nic.ott.hookup.net)
Mon, 9 Sep 1996 09:58:32 -0400 (EDT)


> Has anyone thought of a way to possibly put a limit on the amount of
> resources to alow anyone process. For example the following code is a
> common fork bomb used by people to cause systems to crash. When ran on
> this system it crashs the kernel within seconds and even after its killed
> I have waited an hour, and the harddrive was still spinning :). There has
> to be a way to prevent something like this from causeing such a problem.
>
> main()
> { int *root; while(1) { root=(int *)malloc(10000);
> fork(); } }

You are gonna get mail-bombed for posting this...it has been asked
so many times that some people will throw a tantrum seeing it yet
again. Luckily, I'm in a good mood this morning :-)

The answer: configure your system properly :-)

Read the 'man' pages for the shells you use. All of them have
a way of limiting resources - usually by adding a 'ulimit -Hu 25'
to /etc/profile (to set a HARD limit of 25 processes/user).

--
Andrew E. Mileski
mailto:aem@ott.hookup.net          http://www.redhat.com/~aem/
Linux Plug-and-Play Project Leader http://www.redhat.com/linux-info/pnp/
PGP Public keys are available from http://www.redhat.com/~aem/pgp-keys.txt