Skip to content

Commit bbb3254

Browse files
committed
gh-112970: Wire up closefrom for Linux
glibc-2.34 implements closefrom(3) using the same semantics as on BSD. Check for closefrom in configure and use the check result in fileutils.c rather than hardcoding a FreeBSD check (which was wrong for other BSDs anyway). Signed-off-by: Sam James <[email protected]>
1 parent 3251ba8 commit bbb3254

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Python/fileutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,9 +2878,9 @@ _Py_GetLocaleconvNumeric(struct lconv *lc,
28782878
* non-opened fd in the middle.
28792879
* 2b. If fdwalk(3) isn't available, just do a plain close(2) loop.
28802880
*/
2881-
#ifdef __FreeBSD__
2881+
#ifdef HAVE_CLOSEFROM
28822882
# define USE_CLOSEFROM
2883-
#endif /* __FreeBSD__ */
2883+
#endif /* HAVE_CLOSEFROM */
28842884

28852885
#ifdef HAVE_FDWALK
28862886
# define USE_FDWALK

configure

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4743,7 +4743,7 @@ fi
47434743

47444744
# checks for library functions
47454745
AC_CHECK_FUNCS([ \
4746-
accept4 alarm bind_textdomain_codeset chmod chown clock close_range confstr \
4746+
accept4 alarm bind_textdomain_codeset chmod chown clock closefrom close_range confstr \
47474747
copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \
47484748
faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \
47494749
fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@
157157
/* Define to 1 if you have the `clock_settime' function. */
158158
#undef HAVE_CLOCK_SETTIME
159159

160+
/* Define to 1 if you have the `closefrom' function. */
161+
#undef HAVE_CLOSEFROM
162+
160163
/* Define to 1 if you have the `close_range' function. */
161164
#undef HAVE_CLOSE_RANGE
162165

0 commit comments

Comments
 (0)