aboutsummaryrefslogtreecommitdiff
path: root/libc/include/unistd.h
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2022-01-21 11:19:55 -0800
committerMaciej Żenczykowski <maze@google.com>2022-05-06 10:33:04 +0000
commitb65e1050476ec37330129a7de480dc4fb662a05c (patch)
tree8c8542ec2d8c64c34e17b244146b0b64a2c25df4 /libc/include/unistd.h
parent0f6d493d28d4d47a77c73d2c92a60b356dadd70a (diff)
downloadbionic-b65e1050476ec37330129a7de480dc4fb662a05c.tar.gz
add new Linux close_range() system call to bionic
See: https://man7.org/linux/man-pages/man2/close_range.2.html Note: 'man close_range' documents 'flags' as unsigned int, while glibc unistd.h as just 'int'. Picking 'int' to match glibc, though it probably doesn't matter. BYPASS_INCLUSIVE_LANGUAGE_REASON=man is a cli command Test: TreeHugger Bug: 229913920 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1e2d1c8edc2ea28922d60f3ce3e534a784622cd1
Diffstat (limited to 'libc/include/unistd.h')
-rw-r--r--libc/include/unistd.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index e36042187..f142525ba 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -317,6 +317,22 @@ int setdomainname(const char* __name, size_t __n) __INTRODUCED_IN(26);
void swab(const void* __src, void* __dst, ssize_t __byte_count) __INTRODUCED_IN(28);
#endif
+/**
+ * [close_range(2)](https://man7.org/linux/man-pages/man2/close_range.2.html)
+ * performs an action (which depends on value of flags) on an inclusive range
+ * of file descriptors.
+ *
+ * Available since API level 34.
+ *
+ * Note: there is no emulation on too old kernels, hence this will fail with
+ * -1/ENOSYS on pre-5.9 kernels, -1/EINVAL for unsupported flags. In particular
+ * CLOSE_RANGE_CLOEXEC requires 5.11, though support was backported to Android
+ * Common Kernel 5.10-T.
+ *
+ * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ */
+int close_range(unsigned int __min_fd, unsigned int __max_fd, int __flags) __INTRODUCED_IN(34);
+
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
#define _UNISTD_H_
#include <bits/fortify/unistd.h>