Better logging for closing(fd)

This commit is contained in:
Jagger 2016-06-18 11:08:35 +02:00
parent 53d8e16a01
commit da0f4c0695

View File

@ -191,7 +191,6 @@ static bool containPassFd(struct nsjconf_t *nsjconf, int fd)
struct fds_t *p; struct fds_t *p;
TAILQ_FOREACH(p, &nsjconf->open_fds, pointers) { TAILQ_FOREACH(p, &nsjconf->open_fds, pointers) {
if (p->fd == fd) { if (p->fd == fd) {
LOG_D("FD=%d will be passed to the child process", fd);
return true; return true;
} }
} }
@ -209,6 +208,7 @@ static bool containMakeFdsCOENaive(struct nsjconf_t *nsjconf)
continue; continue;
} }
if (containPassFd(nsjconf, fd)) { if (containPassFd(nsjconf, fd)) {
LOG_D("FD=%d will be passed to the child process", fd);
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags & ~(FD_CLOEXEC))); TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags & ~(FD_CLOEXEC)));
} else { } else {
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags | FD_CLOEXEC)); TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags | FD_CLOEXEC));
@ -255,8 +255,10 @@ static bool containMakeFdsCOEProc(struct nsjconf_t *nsjconf)
return false; return false;
} }
if (containPassFd(nsjconf, fd)) { if (containPassFd(nsjconf, fd)) {
LOG_D("FD=%d will be passed to the child process", fd);
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags & ~(FD_CLOEXEC))); TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags & ~(FD_CLOEXEC)));
} else { } else {
LOG_D("FD=%d will be closed before execve()", fd);
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags | FD_CLOEXEC)); TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, flags | FD_CLOEXEC));
} }
} }