]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: use closefrom instead of close_range
authorMike Gilbert <floppym@gentoo.org>
Tue, 9 Dec 2025 04:46:17 +0000 (23:46 -0500)
committerJaroslav Kysela <perex@perex.cz>
Tue, 9 Dec 2025 08:57:11 +0000 (09:57 +0100)
closefrom is a library function with a fallback mechanism for when the
kernel does not support the close_range syscall.

Also check for the function properly instead of assuming it is available
with _GNU_SOURCE defined.

Closes: https://github.com/alsa-project/alsa-lib/pull/486
Fixes: https://github.com/alsa-project/alsa-lib/issues/485
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
configure.ac
src/ucm/ucm_exec.c

index 8f4bd0de1400846db6fb501817ab7195f5cb6f37..f4862f64cd4c6fe551fc9fe19d7f99885c19f376 100644 (file)
@@ -52,6 +52,7 @@ dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 AC_CHECK_FUNCS([uselocale])
 AC_CHECK_FUNCS([eaccess])
+AC_CHECK_DECLS([closefrom])
 
 dnl Enable largefile support
 AC_SYS_LARGEFILE
index b5a22023b680446ba6e8b7ea92f777c7125afbea..713039b4920fffbf2b900d044a880dfb04c260e6 100644 (file)
@@ -259,8 +259,8 @@ int uc_mgr_exec(const char *prog)
 
                close(f);
 
-#if defined(_GNU_SOURCE)
-               close_range(3, maxfd, 0);
+#if HAVE_DECL_CLOSEFROM
+               closefrom(3);
 #else
                for (f = 3; f < maxfd; f++)
                        close(f);