The Fork() bomb is a Dos (Denial of Service) attack on Linux-based systems. This calls the Fork() system an infinite number of times, filling up the program's memory with the intention of harming the system.
fork bomb's Bash script
:(){ :|: & };:
The code is explained as: ( ) is the function definition, { } defines the loop body. :|:& creates a memory location and does not allow it to be freed. The program calls itself multiple times, again and again. This enables unlimited calls.
The C Fork bomb is also the same type of DOS, but it runs on a C compiler. This creates infinite calls to memory allocation and leaves the system running out of memory.
#include <unistd.h> #include <malloc.h> int main() { while (1) { fork(); } }
Infinite calls
The above is the detailed content of C vs BASH Fork bomb? C vs BASH Fork bomb?. For more information, please follow other related articles on the PHP Chinese website!