Skip to content

Commit c83850b

Browse files
committed
Add forkbomb user application
1 parent 38ac1b8 commit c83850b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/usr/local/src/forkbomb.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// multiprocessing example
2+
#include <stdio.h>
3+
#include <process.h>
4+
5+
6+
int main(int argc,char *argv[]) {
7+
while(1) {
8+
int potential_parent_pid = getpid();
9+
int pid = fork();
10+
if(pid<0) {
11+
printf("fork bomb pid: %d says it can't fork anymore\n", potential_parent_pid);
12+
} else if(pid>0) {
13+
printf("new fork bomb pid:%d says thanks to pid:%d\n", pid, potential_parent_pid);
14+
}
15+
}
16+
return 0;
17+
}

0 commit comments

Comments
 (0)