Advertisement
Guest User

Daniel Trebbien

a guest
Sep 3rd, 2010
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <sys/stat.h>
  6.  
  7. int main()
  8. {
  9.     int fildes[2];
  10.     if (pipe(fildes) == -1) {
  11.         const int e = errno;
  12.         fprintf(stderr, "`pipe` failed: %s (%d)\n", strerror(e), e);
  13.         return EXIT_FAILURE;
  14.     }
  15.  
  16.     struct stat buf;
  17.     if (fstat(fildes[0], &buf) == -1) {
  18.         const int e = errno;
  19.         fprintf(stderr, "`fstat` failed: %s (%d)\n", strerror(e), e);
  20.         return EXIT_FAILURE;
  21.     }
  22.  
  23.     printf("buf.st_mode=0x%08x\n", (int)buf.st_mode);
  24.     if (!S_ISFIFO(buf.st_mode)) {
  25.         printf("!");
  26.     }
  27.     printf("S_ISFIFO(buf.st_mode)\n");
  28.  
  29.     return EXIT_SUCCESS;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement