Re: I'm done with O_CLOEXEC



On Fri, 2015-03-20 at 16:43 -0400, Ryan Lortie wrote:
What led me to this was the dup3() system call.  This is a variant of
dup2() that was added (as part of the efforts mentioned above) to avoid
the O_CLOEXEC race:

  int dup3(int oldfd, int newfd, int flags);

unfortunately:

  dup3(0, -1, 0)                          = -1 EBADF (Bad file
  descriptor)

which means that using this as a stand-in for dup() is a no-go.

Doesn't the following standard POSIX functionality provide what you
want?

        fcntl(fd, F_DUPFD_CLOEXEC, 0)

Regards,
Jürg



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