# C vs BASH Fork bomb?

CServer Side ProgrammingProgramming

Fork() bomb is a Dos (Denial Of Service) attack against the linux based system. This calls the Fork() system infinite number of times that fills the memory of the program and intends to harm the system.

Bash script for fork bomb

:(){ :|: & };:

The code explained as :( ) is function definition, { } defines the body of the loop. :|:& create a memory location and does not allow it to get deallocated. This program call itself multiple number of time again and again. Thus calling infinite calls.

C Fork bomb is also the same type of Dos but it can be run on C compiler. That create infinite calls to a memory allocation and runs the system out of memory.

## Example

#include <unistd.h>
#include <malloc.h>
int main() {
while (1) {
fork();
}
}

## Output

Infinite calls
Published on 08-Aug-2019 08:09:29