fcntl.c 331 B

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