Advertisement
Guest User

reader

a guest
May 25th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1.  
  2.  
  3.     #include <fcntl.h>
  4.     #include <stdio.h>
  5.     #include <sys/stat.h>
  6.     #include <unistd.h>
  7.     #define MAX_BUF 1024
  8.     int main()
  9.     {
  10.      int fd;
  11.  
  12.      char * myfifo = "/tmp/myfifo";
  13.      char buf[MAX_BUF];
  14.  
  15.      /* open, read, and display the message from the FIFO */
  16.      fd = open(myfifo, O_RDONLY);
  17.      read(fd, buf, MAX_BUF);
  18.      printf("Odebrano: %s\n", buf);
  19.  
  20.      close(fd);
  21.  
  22.  
  23.      fd = open(myfifo, O_WRONLY);
  24.      write(fd, "Nie.. Nie.. To niemożliwe !!!", sizeof("Nie.. Nie.. To niemożliwe !!!"));
  25.      close(fd);
  26.  
  27.      return 0;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement