Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include <unistd.h>
- #include <sys/wait.h>
- #define NB_FORKS 50000
- void do_nothing(){
- int i;
- i=0;
- exit(EXIT_SUCCESS);
- }
- int main(int argc, char const *argv[])
- {
- int pid,j,status;
- for (j = 0;j<NB_FORKS; j++){
- switch(pid=fork()){
- case -1:
- perror("fork()");
- exit(EXIT_FAILURE);
- case 0:
- do_nothing();
- default:
- waitpid(pid,&status,0);
- break;
- }
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement