Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5. #include <sys/types.h>
  6.  
  7. int main(){
  8. int potok_fd[2] ,licznik ,obraz ,pid;
  9. char bufor[64] ,nazwa[32];
  10.  
  11. pipe(potok_fd); // tworzenie potoku
  12. pid = fork(); // tworzeine procesu potomnego
  13.  
  14.  
  15. if (pid == 0) // fragment kodu zrodlowego zaczerpniety z wykladu Dr. W. Paluszynskiego
  16. {
  17. close(0); //zamkniecie wejścia
  18. dup(potok_fd[0]);
  19. close(potok_fd[0]);
  20. close(potok_fd[1]);
  21. close(1);
  22. execlp("display","display",NULL);
  23. }
  24.  
  25. close(potok_fd[0]);
  26.  
  27. printf("Wprowadz nazwe obrazu: ");
  28. scanf("%s",nazwa);
  29.  
  30. obraz=open(nazwa,O_RDONLY);
  31.  
  32. while ((licznik=read(obraz, bufor, 64)) > 0)
  33. write(potok_fd[1], bufor, licznik);
  34. close(potok_fd[1]);
  35.  
  36. return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement