diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:41:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:41:07 +0000 |
commit | 3af6d22bb3850ab2bac67287e3a3d3b0e32868e5 (patch) | |
tree | 3ee7a3ec64525911fa865bb984c86d997d855527 /man2/close_range.2 | |
parent | Adding debian version 6.05.01-1. (diff) | |
download | manpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.tar.xz manpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.zip |
Merging upstream version 6.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'man2/close_range.2')
-rw-r--r-- | man2/close_range.2 | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/man2/close_range.2 b/man2/close_range.2 index c1aa3db..d9582b0 100644 --- a/man2/close_range.2 +++ b/man2/close_range.2 @@ -3,7 +3,7 @@ .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" -.TH close_range 2 2023-05-03 "Linux man-pages 6.05.01" +.TH close_range 2 2024-02-25 "Linux man-pages 6.7" .SH NAME close_range \- close all file descriptors in a given range .SH LIBRARY @@ -11,10 +11,14 @@ Standard C library .RI ( libc ", " \-lc ) .SH SYNOPSIS .nf -.B #include <linux/close_range.h> -.PP -.BI "int close_range(unsigned int " first ", unsigned int " last , -.BI " unsigned int " flags ); +.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" +.B #include <unistd.h> +.P +.BR "#include <linux/close_range.h>" " /* Definition of " CLOSE_RANGE_* +.BR "" " constants */" +.P +.BI "int close_range(unsigned int " first ", unsigned int " last \ +", int " flags ); .fi .SH DESCRIPTION The @@ -24,9 +28,9 @@ system call closes all open file descriptors from to .I last (included). -.PP +.P Errors closing a given file descriptor are currently ignored. -.PP +.P .I flags is a bit mask containing 0 or more of the following: .TP @@ -53,7 +57,7 @@ is not valid, or .I first is greater than .IR last . -.PP +.P The following can occur with .B CLOSE_RANGE_UNSHARE (when constructing the new descriptor table): @@ -97,7 +101,7 @@ which provides significant performance benefits. .SS Closing file descriptors before exec .\" 60997c3d45d9a67daf01c56d805ae4fec37e0bd8 File descriptors can be closed safely using -.PP +.P .in +4n .EX /* we don't want anything past stderr here */ @@ -105,17 +109,17 @@ close_range(3, \[ti]0U, CLOSE_RANGE_UNSHARE); execve(....); .EE .in -.PP +.P .B CLOSE_RANGE_UNSHARE is conceptually equivalent to -.PP +.P .in +4n .EX unshare(CLONE_FILES); close_range(first, last, 0); .EE .in -.PP +.P but can be more efficient: if the unshared range extends past the current maximum number of file descriptors allocated @@ -168,7 +172,7 @@ uses to close all file descriptors greater than or equal to 3, and then once more displays the process's list of open files. The following example demonstrates the use of the program: -.PP +.P .in +4n .EX $ \fBtouch /tmp/a /tmp/b /tmp/c\fP @@ -190,7 +194,7 @@ $ \fB./a.out /tmp/a /tmp/b /tmp/c\fP /proc/self/fd/3 ==> /proc/9005/fd .EE .in -.PP +.P Note that the lines showing the pathname .I /proc/9005/fd result from the calls to @@ -205,7 +209,6 @@ result from the calls to #include <limits.h> #include <stdio.h> #include <stdlib.h> -#include <sys/syscall.h> #include <unistd.h> \& /* Show the contents of the symbolic links in /proc/self/fd */ @@ -259,7 +262,7 @@ main(int argc, char *argv[]) \& printf("========= About to call close_range() =======\en"); \& - if (syscall(SYS_close_range, 3, \[ti]0U, 0) == \-1) { + if (close_range(3, \[ti]0U, 0) == \-1) { perror("close_range"); exit(EXIT_FAILURE); } |