Skip to content

Commit a068cf0

Browse files
floppymperexg
authored andcommitted
ucm: use closefrom instead of close_range
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: #486 Fixes: #485 Signed-off-by: Mike Gilbert <floppym@gentoo.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
1 parent 70e413c commit a068cf0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dnl Checks for library functions.
5252
AC_PROG_GCC_TRADITIONAL
5353
AC_CHECK_FUNCS([uselocale])
5454
AC_CHECK_FUNCS([eaccess])
55+
AC_CHECK_DECLS([closefrom])
5556

5657
dnl Enable largefile support
5758
AC_SYS_LARGEFILE

src/ucm/ucm_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ int uc_mgr_exec(const char *prog)
259259

260260
close(f);
261261

262-
#if defined(_GNU_SOURCE)
263-
close_range(3, maxfd, 0);
262+
#if HAVE_DECL_CLOSEFROM
263+
closefrom(3);
264264
#else
265265
for (f = 3; f < maxfd; f++)
266266
close(f);

0 commit comments

Comments
 (0)