Advertisement
xPhilz

Untitled

Feb 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <sys/wait.h>
  4. #include <fcntl.h>
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. #include <stdlib.h>
  8.  
  9. main()
  10. {
  11. int i,retv,p;
  12. pid_t pid;
  13.  
  14. for(i=0;i<10;i++)
  15. {
  16. pid=fork();
  17. if(pid==0)
  18. {
  19. printf("Figlio: %d\n",i+1);
  20. sleep(2*(i+1));
  21. return(101+i);
  22. }
  23. }
  24.  
  25. for(i=0;i<10;i++)
  26. {
  27. wait(&retv);
  28. printf("\nProcesso n.%d Terminato: %d",i+1,WEXITSTATUS(retv));
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement