orzechtbg

Współbieżne.LAB4. ZAD1.czytajacy

Oct 28th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <errno.h>
  7. #include <stdlib.h>
  8.  
  9. extern int errno;
  10.  
  11. #define FIFO1 "/tmp/fifo.1"
  12.  
  13. int main(){
  14.         char buff[50];
  15.         int fifo;
  16.         if ((fifo = open(FIFO1, O_RDONLY)) < 0)
  17.             perror("nie moze otworzyc fifo1 do czytania");
  18.         int n=read(fifo,buff,sizeof(buff));
  19. if (n<=0)
  20.     perror("blad zapisu do fifo");
  21. else{
  22. buff[n]='\0';
  23.                 write(1,buff,n);
  24.          printf("\n");
  25.         }
  26.    
  27.    
  28.         exit(0);    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment