Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. for (pipeFlag; pipeFlag > 0; pipeFlag--){
  2. pipeIndex = pipeFlag%2;
  3. filedes[pipeIndex][0]=0;
  4. filedes[pipeIndex][1]=0;
  5. pipe(filedes[pipeIndex]);
  6. CHK( childpid = fork());
  7. if (childpid == 0){
  8. outputFlag = 0;
  9. dup2(filedes[pipeIndex][1], STDOUT_FILENO);
  10. if(pipeAmpFlag != 0){
  11. dup2(filedes[pipeIndex][1], STDERR_FILENO);
  12. pipeAmpFlag = 0;
  13. }
  14. close(filedes[pipeIndex][0]);
  15. close(filedes[pipeIndex][1]);
  16. pipeLocation -=2;
  17. while(newargv[pipeLocation] != 0 && pipeLocation >= 0)
  18. pipeLocation--;
  19. pipeLocation++;
  20. }else{
  21. inputFlag = 0;
  22. dup2(filedes[pipeIndex][0], STDIN_FILENO);
  23. close(filedes[pipeIndex][0]);
  24. close(filedes[pipeIndex][1]);
  25. break;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement