int fd = open("/some/file", O_RDWR); dup2(fd, 7); close(fd);