Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. include <stdio.h>
  2. #include <sys/types.h>
  3. //#include <sys/wait.h>
  4. #include <sys/stat.h>
  5. #include <fcntl.h>
  6. #include<string.h>
  7. #include <unistd.h>
  8.  
  9. int main(void){
  10.  
  11. int pid=fork();
  12. if (pid>0){
  13. int lacze;
  14. char tekst[10]="tekst";
  15. if ((mkfifo("fifo",0600))==-1)
  16. printf("Blad (fifo)\n");
  17. lacze = open("fifo",O_WRONLY);
  18. if((write(lacze,tekst,10))==-1)
  19. printf("Blad (write)\n");
  20. close(lacze);
  21. unlink("fifo");
  22.  
  23. }
  24. return 0;
  25. }
  26.  
  27.  
  28.  
  29. zad6
  30.  
  31. #include <stdio.h>
  32. #include <sys/types.h>
  33. #include <sys/wait.h>
  34. #include <sys/stat.h>
  35. #include <fcntl.h>
  36. #include <string.h>
  37. #include <unistd.h>
  38.  
  39. int main(void){
  40. int pid = fork();
  41. if (pid > 0) {
  42. int lacze;
  43. char tekst[10];
  44. lacze = open("fifo",O_RDONLY);
  45. if((read(lacze,tekst,20))==-1)
  46. printf("Blad (read)\n");
  47. printf("%s\n",tekst);
  48. close(lacze);
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement