NoPaste.me

Secure and Anonymous

Login

  • Only for Administration!
Time 28.06.2011 - 16:14
Code Language C++
This paste is public Public
Show Options
  1. //open and reads a pipe
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. //Pipe call
  5. #include <fcntl.h>
  6. //mknod call
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9.  
  10. #define BUFLEN 100
  11.  
  12. //Protoypes
  13. int main(void);
  14.  
  15. //Vars
  16. int fdes;
  17. char buffer[BUFLEN];
  18. char c;
  19.  
  20. int main(void)
  21. {
  22.         //A pipe gets opend in "read only" mode.
  23.         if((fdes=open("pipe1",O_RDONLY))==(-1))
  24.         {
  25.         printf("Error couldn't open pipe");
  26.         exit(-1);
  27.         }
  28.         read(fdes,buffer,BUFLEN);
  29.         puts(buffer);
  30.         close(fdes);
  31.         exit(0);
  32. }