22 lines
381 B
C
22 lines
381 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#define FORKS 800
|
|
|
|
int main(void) {
|
|
for (int i = 0; i < FORKS; i++) {
|
|
pid_t pid = fork();
|
|
|
|
switch (pid) {
|
|
case -1:
|
|
perror("Fork failed\n");
|
|
break;
|
|
case 0:
|
|
while (1) sleep(5);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
printf("Forked %d processes. Letting someone else clean up. Bye.\n", FORKS);
|
|
}
|