set the close-on-exec flag on all file descriptors

Added the "fd_util" library, which attempts to use the new thread-safe
Linux system calls pipe2(), accept4() and the options O_CLOEXEC,
SOCK_CLOEXEC.  Without these, it falls back to FD_CLOEXEC, which is
not thread safe.

This is particularly important for the "pipe" output plugin (and
others, such as JACK/PulseAudio), because we were heavily leaking file
descriptors to child processes.
This commit is contained in:
Max Kellermann
2009-11-07 18:55:16 +01:00
parent 9b21152600
commit e3af0032b2
17 changed files with 271 additions and 24 deletions

View File

@@ -115,12 +115,14 @@ fi
AC_CHECK_LIB(socket,socket,MPD_LIBS="$MPD_LIBS -lsocket",)
AC_CHECK_LIB(nsl,gethostbyname,MPD_LIBS="$MPD_LIBS -lnsl",)
AC_CHECK_FUNCS(pipe2 accept4)
AC_CHECK_LIB(m,exp,MPD_LIBS="$MPD_LIBS -lm",)
AC_CHECK_HEADERS(locale.h)
AC_CHECK_HEADERS(valgrind/memcheck.h)
AC_CHECK_FUNCS(inotify_init)
AC_CHECK_FUNCS(inotify_init inotify_init1)
AC_ARG_ENABLE(inotify,
AS_HELP_STRING([--disable-inotify],
[disable support Inotify automatic database update (default: enabled) ]),,