提交 4b9919af 编写于 作者: D Daniel P. Berrangé

src: conditionalize use of F_DUPFD_CLOEXEC

The F_DUPFD_CLOEXEC functionality is not available on
some platformms. We must thus explicitly call the
virSetCloexec function once we remove GNULIB's equiv
fix for this.
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 2a656fc9
......@@ -1397,15 +1397,27 @@ int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec)
{
int fd;
#ifdef F_DUPFD_CLOEXEC
if (cloexec)
fd = fcntl(sock->fd, F_DUPFD_CLOEXEC, 0);
else
#endif /* F_DUPFD_CLOEXEC */
fd = dup(sock->fd);
if (fd < 0) {
virReportSystemError(errno, "%s",
_("Unable to copy socket file handle"));
return -1;
}
#ifndef F_DUPFD_CLOEXEC
if (cloexec &&
virSetCloseExec(fd < 0)) {
int saveerr = errno;
closesocket(fd);
errno = saveerr;
return -1;
}
#endif /* F_DUPFD_CLOEXEC */
return fd;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册