Advertisement
Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <errno.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <fcntl.h>
  7. #include <limits.h>
  8.  
  9. int main(void){
  10. int fd;
  11. int len;
  12. char buf[PIPE_BUF];
  13. mode_t mode = 0666;
  14.  
  15. if((mkfifo("fifo1",mode))<0){
  16. perror("mkfifo");
  17. exit(EXIT_FAILURE);
  18. }
  19. if((fd=open("fifo1",O_RDONLY))<0){
  20. perror("open");
  21. exit(EXIT_FAILURE);
  22. }
  23. while((len = read(fd,buf,PIPE_BUF -1)) > 0)
  24. printf("rdfifo read: %s",buf);
  25. close(fd);
  26. exit(EXIT_SUCCESS);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement