Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. for(i = 0; i < argc-1; i++){
  2. pipe(pipes[i]);
  3. pids[i] = fork();
  4.  
  5. if(pids[i] == 0){
  6.  
  7. pids_child[i] = fork();
  8.  
  9. if(pids_child[i]==0){
  10. close(pipes[i][0]);
  11. dup2(pipes[i][1],1);
  12. close(pipes[i][1]);
  13. execl(argv[i+1], argv[i+1], NULL);
  14. _exit(0);
  15. } else {
  16. close(pipes[i][1]);
  17. alarm(3);
  18. while((bytes_r = read(pipes[i][0], buf, 1024)) > 0){
  19. printf("merdas\n");
  20. if(!(strcmp("OK\n",buf))){
  21. succ++;
  22. printf("%d\n", succ);
  23. }
  24. }
  25. }
  26. } else {
  27. times[i] = 3 * count;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement