mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-112970: Detect and use closefrom() when available (#112969)
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. Some implementations of closefrom() return an int. Explicitly discard the return value by casting it to void, to avoid future compiler warnings. Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
parent
0d2fe6bab0
commit
c454e934d3
5 changed files with 14 additions and 4 deletions
|
@ -2878,9 +2878,9 @@ done:
|
|||
* non-opened fd in the middle.
|
||||
* 2b. If fdwalk(3) isn't available, just do a plain close(2) loop.
|
||||
*/
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef HAVE_CLOSEFROM
|
||||
# define USE_CLOSEFROM
|
||||
#endif /* __FreeBSD__ */
|
||||
#endif /* HAVE_CLOSEFROM */
|
||||
|
||||
#ifdef HAVE_FDWALK
|
||||
# define USE_FDWALK
|
||||
|
@ -2922,7 +2922,7 @@ _Py_closerange(int first, int last)
|
|||
#ifdef USE_CLOSEFROM
|
||||
if (last >= sysconf(_SC_OPEN_MAX)) {
|
||||
/* Any errors encountered while closing file descriptors are ignored */
|
||||
closefrom(first);
|
||||
(void)closefrom(first);
|
||||
}
|
||||
else
|
||||
#endif /* USE_CLOSEFROM */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue