mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
linux: Add close_range
It was added on Linux 5.9 (278a5fbaed89) with CLOSE_RANGE_CLOEXEC added on 5.11 (582f1fb6b721f). Although FreeBSD has added the same syscall, this only adds the symbol on Linux ports. This syscall is required to provided a fail-safe way to implement the closefrom symbol (BZ #10353). Checked on x86_64-linux-gnu and i686-linux-gnu on kernel 5.11 and 4.15.
This commit is contained in:
@ -33,4 +33,27 @@
|
||||
not detached and has not been joined. */
|
||||
extern __pid_t gettid (void) __THROW;
|
||||
|
||||
#ifdef __has_include
|
||||
# if __has_include ("linux/close_range.h")
|
||||
# include "linux/close_range.h"
|
||||
# endif
|
||||
#endif
|
||||
/* Unshare the file descriptor table before closing file descriptors. */
|
||||
#ifndef CLOSE_RANGE_UNSHARE
|
||||
# define CLOSE_RANGE_UNSHARE (1U << 1)
|
||||
#endif
|
||||
/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */
|
||||
#ifndef CLOSE_RANGE_CLOEXEC
|
||||
# define CLOSE_RANGE_CLOEXEC (1U << 2)
|
||||
#endif
|
||||
|
||||
/* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS
|
||||
are define by the CLOSE_RANGE prefix. This function behaves like close
|
||||
on the range, but in a fail-safe where it will either fail and not close
|
||||
any file descriptor or close all of them. Gaps where the file descriptor
|
||||
is invalid are ignored. Returns 0 on successor or -1 for failure (and
|
||||
sets errno accordingly). */
|
||||
extern int close_range (unsigned int __fd, unsigned int __max_fd,
|
||||
int __flags) __THROW;
|
||||
|
||||
#endif /* __USE_GNU */
|
||||
|
Reference in New Issue
Block a user