AC_FUNC_STRCOLL
dnl Check for non-standard system calls
-AC_CHECK_FUNCS([accept4 dup3 pipe2 eventfd vmsplice sched_getaffinity])
+AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity])
AH_BOTTOM([#include <vlc_fixups.h>])
{
int newfd;
-#ifdef HAVE_DUP3
- /* Unfortunately, dup3() works like dup2(), not like plain dup(). So we
- * need such contortion to find the new file descriptor while preserving
- * thread safety of the file descriptor table. */
- newfd = vlc_open ("/dev/null", O_RDONLY);
- if (likely(newfd != -1))
+#ifdef F_DUPFD_CLOEXEC
+ newfd = fcntl (oldfd, F_DUPFD_CLOEXEC);
+ if (unlikely(newfd == -1 && errno == EINVAL))
+#endif
{
- if (likely(dup3 (oldfd, newfd, O_CLOEXEC) == newfd))
- return newfd;
- close (newfd);
+ newfd = dup (oldfd);
+ if (likely(newfd != -1))
+ fcntl (newfd, F_SETFD, FD_CLOEXEC);
}
-#endif
-
- newfd = dup (oldfd);
- if (likely(newfd != -1))
- fcntl (newfd, F_SETFD, FD_CLOEXEC);
return newfd;
}