Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
51
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 <unistd.h>
  3. #include <fcntl.h>
  4. #include <sysy/stat.h>
  5. #include <sys/mman.h>
  6. #include <sys/types.h>
  7.  
  8.  
  9. int main()
  10. {
  11. int pid, licznik ,plik ,rozmiar;
  12. char bufor[64], nazwa [32];
  13.  
  14. int shmd;
  15. char *mem_ptr;
  16. struct stat filestat;
  17.  
  18. pid=fork()
  19.  
  20.  
  21. if (pid ==0)
  22. {
  23. stat("map.pgm",&filestat);
  24. execlp("display","display","map.pgm",NULL);
  25. }
  26.  
  27. else if(pid > 0)
  28. {
  29.  
  30. while(1)
  31. {
  32. printf("Wprowadz nazwe obrazka: ");
  33. scanf("%s",nazwa);
  34. plik=open(nazwa,O_RDONLY);
  35. fstat(plik,&filestat);
  36. rozmiar=filestat.st_size;
  37. shmd=open("map.pgm",O_RDWR);
  38. ftruncate(shmd,filestat.st_size);
  39. mem_ptr=(char*)mmap(pom,staty.st_size, PROT_READ | PROT_WRITE, MAP_SHARED,map,0);
  40. }
  41. while((licznik=read(plik,bufor,64))>0)
  42.  
  43. close(plik);
  44. close(shmd);
  45. }
  46.  
  47. return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement