Advertisement
Guest User

Untitled

a guest
May 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <unistd.h>
  4.  
  5.  
  6.  
  7. int potok[2];
  8.  
  9.  
  10.  
  11. int main(){
  12.  
  13. pipe(potok); // utworzenie potoku pipe
  14.  
  15.  
  16.  
  17. switch(fork()) // tworznie procesu
  18.  
  19. {
  20.  
  21. case -1: // blad utworzenia
  22.  
  23. exit(1);
  24.  
  25.  
  26.  
  27. case 0: // potomny po A
  28.  
  29. close(1);
  30.  
  31. dup(potok[1]); // wpisanie do potoku
  32.  
  33. close(potok[0]);
  34.  
  35. execlp("finger", "finger", NULL);
  36.  
  37. exit(0);
  38.  
  39.  
  40.  
  41. default: // macierzysty A
  42.  
  43. {
  44.  
  45. wait();
  46.  
  47. close(0);
  48.  
  49. dup(potok[0]); // odczyt z potoku
  50.  
  51. close(potok[1]);
  52.  
  53. execlp("cut", "cut", "-d ", "-f1", NULL);
  54.  
  55. }
  56.  
  57. }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement