Home > Article > Backend Development > In C/C++, C vs BASH Fork bomb means the fork bomb of C language and BASH language.
It has been established that the BASH fork bomb is much more powerful than its C program counterpart. The main reason is that the process created in BASH is detached from the parent process. If the parent process (the one we initially started) is destroyed or terminated, the remaining processes will continue to exist. But in the case of the C implementation, the listed child processes are automatically terminated if the parent process is destroyed or terminated. The script is responsible for communicating directly with the system.
The fork bomb program in C language can be updated or modified. We can allocate memory in the program when creating the fork process.
The following program is considered an implementation of a modified C fork bomb -
// Modified fork bomb #include <unistd.h> #include <malloc.h> int main(){ // Infinite loop while (1){ // Generating child fork processes fork(); // Allocating memory in RAM int *p1 = (int *) malloc (sizeof (int) * 100000); } }
The above is the detailed content of In C/C++, C vs BASH Fork bomb means the fork bomb of C language and BASH language.. For more information, please follow other related articles on the PHP Chinese website!