if (which != EV_READ)
goto out;
- if ((len = read(ic->ic_fd, buf, sizeof(buf))) == -1) {
+ if ((len = read(ic->ic_fd, buf, sizeof(buf))) <= 0) {
idmapd_warnx("nfsdcb: read(%s) failed: errno %d (%s)",
- ic->ic_path, errno, strerror(errno));
+ ic->ic_path, len?errno:0,
+ len?strerror(errno):"End of File");
goto out;
}
if (noclose == 0) {
tempfd = open("/dev/null", O_RDWR);
- dup2(tempfd, 0);
- dup2(tempfd, 1);
- dup2(tempfd, 2);
- closeall(3);
+ if (tempfd < 0)
+ tempfd = open("/", O_RDONLY);
+ if (tempfd >= 0) {
+ dup2(tempfd, 0);
+ dup2(tempfd, 1);
+ dup2(tempfd, 2);
+ closeall(3);
+ } else
+ closeall(0);
}
return;