tmpfd = dup(fd);
d = fdopendir(tmpfd);
if (d == NULL) {
close(fmpfd);
close(tmpfd);
warnx("Impossible to open the directory %s", dir);
return (0);
}