[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 5/8] Extend RPC protocol to allow FD passing



On 10/28/2011 02:28 AM, Daniel P. Berrange wrote:
+    if ((fd = dup(msg->fds[slot]))<   0) {
+        virReportSystemError(errno,
+                             _("Unable to duplicate FD %d"),
+                             msg->fds[slot]);
+        return -1;
+    }

Do we want to be using gnulib's dup_cloexec ("cloexec.h") or
fcntl(fd, F_DUPFD_CLOEXEC, 0) here, so that our dup doesn't leak
into a third-party child if we are linked into some larger
multithreaded app?

dup3() is the new glibc API for this ? Does gnulib support
that yet ?

Gnulib supports dup3(). But dup3() is not the same as dup(); it is the same as dup2(). That is:

dup(fd) maps to fcntl(fd, F_DUPFD_CLOEXEC,0) == dup_cloexec(fd)
dup2(fd1, fd2) maps to dup3(fd1, fd2, O_CLOEXEC)

--
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]