fcntl.c 362 B

123456789101112131415
  1. #include <fcntl.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. int main(void) {
  6. //Lose our fd and pull it again
  7. creat("fcntl.out", 0777);
  8. int newfd = open("fcntl.out", 0);
  9. int newfd2 = fcntl(newfd, F_DUPFD, 0);
  10. printf("fd %d duped into fd %d\n", newfd, newfd2);
  11. close(newfd);
  12. close(newfd2);
  13. return EXIT_SUCCESS;
  14. }