| 1 |
# SOME DESCRIPTIVE TITLE |
| 2 |
# Copyright (C) YEAR Free Software Foundation, Inc. |
| 3 |
# This file is distributed under the same license as the PACKAGE package. |
| 4 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 |
# |
| 6 |
#, fuzzy |
| 7 |
msgid "" |
| 8 |
msgstr "" |
| 9 |
"Project-Id-Version: PACKAGE VERSION\n" |
| 10 |
"POT-Creation-Date: 2026-06-05 06:20+0200\n" |
| 11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 13 |
"Language-Team: LANGUAGE <[email protected]>\n" |
| 14 |
"Language: \n" |
| 15 |
"MIME-Version: 1.0\n" |
| 16 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 17 |
"Content-Transfer-Encoding: 8bit\n" |
| 18 |
|
| 19 |
#. type: TH |
| 20 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 21 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 22 |
#, no-wrap |
| 23 |
msgid "close_range" |
| 24 |
msgstr "" |
| 25 |
|
| 26 |
#. type: TH |
| 27 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 28 |
#: opensuse-tumbleweed |
| 29 |
#, no-wrap |
| 30 |
msgid "2026-02-08" |
| 31 |
msgstr "" |
| 32 |
|
| 33 |
#. type: TH |
| 34 |
#: archlinux debian-unstable |
| 35 |
#, no-wrap |
| 36 |
msgid "Linux man-pages 6.18" |
| 37 |
msgstr "" |
| 38 |
|
| 39 |
#. type: SH |
| 40 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 41 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 42 |
#, no-wrap |
| 43 |
msgid "NAME" |
| 44 |
msgstr "" |
| 45 |
|
| 46 |
#. type: Plain text |
| 47 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 48 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 49 |
msgid "close_range - close all file descriptors in a given range" |
| 50 |
msgstr "" |
| 51 |
|
| 52 |
#. type: SH |
| 53 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 54 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 55 |
#, no-wrap |
| 56 |
msgid "LIBRARY" |
| 57 |
msgstr "" |
| 58 |
|
| 59 |
#. type: Plain text |
| 60 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 61 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 62 |
msgid "Standard C library (I<libc>,\\ I<-lc>)" |
| 63 |
msgstr "" |
| 64 |
|
| 65 |
#. type: SH |
| 66 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 67 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 68 |
#, no-wrap |
| 69 |
msgid "SYNOPSIS" |
| 70 |
msgstr "" |
| 71 |
|
| 72 |
#. type: Plain text |
| 73 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 74 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 75 |
#, no-wrap |
| 76 |
msgid "" |
| 77 |
"B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n" |
| 78 |
"B<#include E<lt>unistd.hE<gt>>\n" |
| 79 |
msgstr "" |
| 80 |
|
| 81 |
#. type: Plain text |
| 82 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 83 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 84 |
#, no-wrap |
| 85 |
msgid "" |
| 86 |
"B<#include E<lt>linux/close_range.hE<gt>> /* Definition of B<CLOSE_RANGE_*>\n" |
| 87 |
" constants */\n" |
| 88 |
msgstr "" |
| 89 |
|
| 90 |
#. type: Plain text |
| 91 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 92 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 93 |
#, no-wrap |
| 94 |
msgid "B<int close_range(unsigned int >I<first>B<, unsigned int >I<last>B<, int >I<flags>B<);>\n" |
| 95 |
msgstr "" |
| 96 |
|
| 97 |
#. type: SH |
| 98 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 99 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 100 |
#, no-wrap |
| 101 |
msgid "DESCRIPTION" |
| 102 |
msgstr "" |
| 103 |
|
| 104 |
#. type: Plain text |
| 105 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 106 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 107 |
msgid "" |
| 108 |
"The B<close_range>() system call closes all open file descriptors from " |
| 109 |
"I<first> to I<last> (included)." |
| 110 |
msgstr "" |
| 111 |
|
| 112 |
#. type: Plain text |
| 113 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 114 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 115 |
msgid "Errors closing a given file descriptor are currently ignored." |
| 116 |
msgstr "" |
| 117 |
|
| 118 |
#. type: Plain text |
| 119 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 120 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 121 |
msgid "I<flags> is a bit mask containing 0 or more of the following:" |
| 122 |
msgstr "" |
| 123 |
|
| 124 |
#. type: TP |
| 125 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 126 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 127 |
#, no-wrap |
| 128 |
msgid "B<CLOSE_RANGE_CLOEXEC> (since Linux 5.11)" |
| 129 |
msgstr "" |
| 130 |
|
| 131 |
#. type: Plain text |
| 132 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 133 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 134 |
msgid "" |
| 135 |
"Set the close-on-exec flag on the specified file descriptors, rather than " |
| 136 |
"immediately closing them." |
| 137 |
msgstr "" |
| 138 |
|
| 139 |
#. type: TP |
| 140 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 141 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 142 |
#, no-wrap |
| 143 |
msgid "B<CLOSE_RANGE_UNSHARE>" |
| 144 |
msgstr "" |
| 145 |
|
| 146 |
#. type: Plain text |
| 147 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 148 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 149 |
msgid "" |
| 150 |
"Unshare the specified file descriptors from any other processes before " |
| 151 |
"closing them, avoiding races with other threads sharing the file descriptor " |
| 152 |
"table." |
| 153 |
msgstr "" |
| 154 |
|
| 155 |
#. type: SH |
| 156 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 157 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 158 |
#, no-wrap |
| 159 |
msgid "RETURN VALUE" |
| 160 |
msgstr "" |
| 161 |
|
| 162 |
#. type: Plain text |
| 163 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 164 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 165 |
msgid "" |
| 166 |
"On success, B<close_range>() returns 0. On error, -1 is returned and " |
| 167 |
"I<errno> is set to indicate the error." |
| 168 |
msgstr "" |
| 169 |
|
| 170 |
#. type: SH |
| 171 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 172 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 173 |
#, no-wrap |
| 174 |
msgid "ERRORS" |
| 175 |
msgstr "" |
| 176 |
|
| 177 |
#. type: TP |
| 178 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 179 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 180 |
#, no-wrap |
| 181 |
msgid "B<EINVAL>" |
| 182 |
msgstr "" |
| 183 |
|
| 184 |
#. type: Plain text |
| 185 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 186 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 187 |
msgid "I<flags> is not valid, or I<first> is greater than I<last>." |
| 188 |
msgstr "" |
| 189 |
|
| 190 |
#. type: Plain text |
| 191 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 192 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 193 |
msgid "" |
| 194 |
"The following can occur with B<CLOSE_RANGE_UNSHARE> (when constructing the " |
| 195 |
"new descriptor table):" |
| 196 |
msgstr "" |
| 197 |
|
| 198 |
#. type: TP |
| 199 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 200 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 201 |
#, no-wrap |
| 202 |
msgid "B<EMFILE>" |
| 203 |
msgstr "" |
| 204 |
|
| 205 |
#. type: Plain text |
| 206 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 207 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 208 |
msgid "" |
| 209 |
"The number of open file descriptors exceeds the limit specified in I</proc/" |
| 210 |
"sys/fs/nr_open> (see B<proc>(5)). This error can occur in situations where " |
| 211 |
"that limit was lowered before a call to B<close_range>() where the " |
| 212 |
"B<CLOSE_RANGE_UNSHARE> flag is specified." |
| 213 |
msgstr "" |
| 214 |
|
| 215 |
#. type: TP |
| 216 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 217 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 218 |
#, no-wrap |
| 219 |
msgid "B<ENOMEM>" |
| 220 |
msgstr "" |
| 221 |
|
| 222 |
#. type: Plain text |
| 223 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 224 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 225 |
msgid "Insufficient kernel memory was available." |
| 226 |
msgstr "" |
| 227 |
|
| 228 |
#. type: SH |
| 229 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 230 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 231 |
#, no-wrap |
| 232 |
msgid "STANDARDS" |
| 233 |
msgstr "" |
| 234 |
|
| 235 |
#. type: Plain text |
| 236 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 237 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 238 |
msgid "None." |
| 239 |
msgstr "" |
| 240 |
|
| 241 |
#. type: SH |
| 242 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 243 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 244 |
#, no-wrap |
| 245 |
msgid "HISTORY" |
| 246 |
msgstr "" |
| 247 |
|
| 248 |
#. type: Plain text |
| 249 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 250 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 251 |
msgid "FreeBSD. Linux 5.9, glibc 2.34." |
| 252 |
msgstr "" |
| 253 |
|
| 254 |
#. type: SH |
| 255 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 256 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 257 |
#, no-wrap |
| 258 |
msgid "NOTES" |
| 259 |
msgstr "" |
| 260 |
|
| 261 |
#. type: SS |
| 262 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 263 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 264 |
#, no-wrap |
| 265 |
msgid "Closing all open file descriptors" |
| 266 |
msgstr "" |
| 267 |
|
| 268 |
#. 278a5fbaed89dacd04e9d052f4594ffd0e0585de |
| 269 |
#. type: Plain text |
| 270 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 271 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 272 |
msgid "" |
| 273 |
"To avoid blindly closing file descriptors in the range of possible file " |
| 274 |
"descriptors, this is sometimes implemented (on Linux) by listing open file " |
| 275 |
"descriptors in I</proc/self/fd/> and calling B<close>(2) on each one. " |
| 276 |
"B<close_range>() can take care of this without requiring I</proc> and " |
| 277 |
"within a single system call, which provides significant performance benefits." |
| 278 |
msgstr "" |
| 279 |
|
| 280 |
#. type: SS |
| 281 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 282 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 283 |
#, no-wrap |
| 284 |
msgid "Closing file descriptors before exec" |
| 285 |
msgstr "" |
| 286 |
|
| 287 |
#. 60997c3d45d9a67daf01c56d805ae4fec37e0bd8 |
| 288 |
#. type: Plain text |
| 289 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 290 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 291 |
msgid "File descriptors can be closed safely using" |
| 292 |
msgstr "" |
| 293 |
|
| 294 |
#. type: Plain text |
| 295 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 296 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 297 |
#, no-wrap |
| 298 |
msgid "" |
| 299 |
"/* we don't want anything past stderr here */\n" |
| 300 |
"close_range(3, \\[ti]0U, CLOSE_RANGE_UNSHARE);\n" |
| 301 |
"execve(....);\n" |
| 302 |
msgstr "" |
| 303 |
|
| 304 |
#. type: Plain text |
| 305 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 306 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 307 |
msgid "B<CLOSE_RANGE_UNSHARE> is conceptually equivalent to" |
| 308 |
msgstr "" |
| 309 |
|
| 310 |
#. type: Plain text |
| 311 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 312 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 313 |
#, no-wrap |
| 314 |
msgid "" |
| 315 |
"unshare(CLONE_FILES);\n" |
| 316 |
"close_range(first, last, 0);\n" |
| 317 |
msgstr "" |
| 318 |
|
| 319 |
#. type: Plain text |
| 320 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 321 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 322 |
msgid "" |
| 323 |
"but can be more efficient: if the unshared range extends past the current " |
| 324 |
"maximum number of file descriptors allocated in the caller's file descriptor " |
| 325 |
"table (the common case when I<last> is \\[ti]0U), the kernel will unshare a " |
| 326 |
"new file descriptor table for the caller up to I<first>, copying as few file " |
| 327 |
"descriptors as possible. This avoids subsequent B<close>(2) calls " |
| 328 |
"entirely; the whole operation is complete once the table is unshared." |
| 329 |
msgstr "" |
| 330 |
|
| 331 |
#. type: SS |
| 332 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 333 |
#: opensuse-tumbleweed |
| 334 |
#, no-wrap |
| 335 |
msgid "Closing files on \\f[I]exec\\fB" |
| 336 |
msgstr "" |
| 337 |
|
| 338 |
#. 582f1fb6b721facf04848d2ca57f34468da1813e |
| 339 |
#. type: Plain text |
| 340 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 341 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 342 |
msgid "" |
| 343 |
"This is particularly useful in cases where multiple pre-B<exec> setup steps " |
| 344 |
"risk conflicting with each other. For example, setting up a B<seccomp>(2) " |
| 345 |
"profile can conflict with a B<close_range>() call: if the file descriptors " |
| 346 |
"are closed before the B<seccomp>(2) profile is set up, the profile setup " |
| 347 |
"can't use them itself, or control their closure; if the file descriptors are " |
| 348 |
"closed afterwards, the seccomp profile can't block the B<close_range>() " |
| 349 |
"call or any fallbacks. Using B<CLOSE_RANGE_CLOEXEC> avoids this: the " |
| 350 |
"descriptors can be marked before the B<seccomp>(2) profile is set up, and " |
| 351 |
"the profile can control access to B<close_range>() without affecting the " |
| 352 |
"calling process." |
| 353 |
msgstr "" |
| 354 |
|
| 355 |
#. type: SH |
| 356 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 357 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 358 |
#, no-wrap |
| 359 |
msgid "EXAMPLES" |
| 360 |
msgstr "" |
| 361 |
|
| 362 |
#. type: Plain text |
| 363 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 364 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 365 |
msgid "" |
| 366 |
"The program shown below opens the files named in its command-line arguments, " |
| 367 |
"displays the list of files that it has opened (by iterating through the " |
| 368 |
"entries in I</proc/PID/fd>), uses B<close_range>() to close all file " |
| 369 |
"descriptors greater than or equal to 3, and then once more displays the " |
| 370 |
"process's list of open files. The following example demonstrates the use of " |
| 371 |
"the program:" |
| 372 |
msgstr "" |
| 373 |
|
| 374 |
#. type: Plain text |
| 375 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 376 |
#: opensuse-tumbleweed |
| 377 |
#, no-wrap |
| 378 |
msgid "" |
| 379 |
"$B< touch /tmp/a /tmp/b /tmp/c>;\n" |
| 380 |
"$B< ./a.out /tmp/a /tmp/b /tmp/c>;\n" |
| 381 |
"/tmp/a opened as FD 3\n" |
| 382 |
"/tmp/b opened as FD 4\n" |
| 383 |
"/tmp/c opened as FD 5\n" |
| 384 |
"/proc/self/fd/0 ==E<gt> /dev/pts/1\n" |
| 385 |
"/proc/self/fd/1 ==E<gt> /dev/pts/1\n" |
| 386 |
"/proc/self/fd/2 ==E<gt> /dev/pts/1\n" |
| 387 |
"/proc/self/fd/3 ==E<gt> /tmp/a\n" |
| 388 |
"/proc/self/fd/4 ==E<gt> /tmp/b\n" |
| 389 |
"/proc/self/fd/5 ==E<gt> /tmp/c\n" |
| 390 |
"/proc/self/fd/6 ==E<gt> /proc/9005/fd\n" |
| 391 |
"========= About to call close_range() =======\n" |
| 392 |
"/proc/self/fd/0 ==E<gt> /dev/pts/1\n" |
| 393 |
"/proc/self/fd/1 ==E<gt> /dev/pts/1\n" |
| 394 |
"/proc/self/fd/2 ==E<gt> /dev/pts/1\n" |
| 395 |
"/proc/self/fd/3 ==E<gt> /proc/9005/fd\n" |
| 396 |
msgstr "" |
| 397 |
|
| 398 |
#. type: Plain text |
| 399 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 400 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 401 |
msgid "" |
| 402 |
"Note that the lines showing the pathname I</proc/9005/fd> result from the " |
| 403 |
"calls to B<opendir>(3)." |
| 404 |
msgstr "" |
| 405 |
|
| 406 |
#. type: SS |
| 407 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 408 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 409 |
#, no-wrap |
| 410 |
msgid "Program source" |
| 411 |
msgstr "" |
| 412 |
|
| 413 |
#. type: Plain text |
| 414 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 415 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 416 |
#, no-wrap |
| 417 |
msgid "" |
| 418 |
"#define _GNU_SOURCE\n" |
| 419 |
"#include E<lt>dirent.hE<gt>\n" |
| 420 |
"#include E<lt>fcntl.hE<gt>\n" |
| 421 |
"#include E<lt>limits.hE<gt>\n" |
| 422 |
"#include E<lt>stdio.hE<gt>\n" |
| 423 |
"#include E<lt>stdlib.hE<gt>\n" |
| 424 |
"#include E<lt>sys/types.hE<gt>\n" |
| 425 |
"#include E<lt>unistd.hE<gt>\n" |
| 426 |
"\\&\n" |
| 427 |
"/* Show the contents of the symbolic links in /proc/self/fd */\n" |
| 428 |
"\\&\n" |
| 429 |
"static void\n" |
| 430 |
"show_fds(void)\n" |
| 431 |
"{\n" |
| 432 |
" DIR *dirp;\n" |
| 433 |
" char path[PATH_MAX], target[PATH_MAX];\n" |
| 434 |
" ssize_t len;\n" |
| 435 |
" struct dirent *dp;\n" |
| 436 |
"\\&\n" |
| 437 |
" dirp = opendir(\"/proc/self/fd\");\n" |
| 438 |
" if (dirp == NULL) {\n" |
| 439 |
" perror(\"opendir\");\n" |
| 440 |
" exit(EXIT_FAILURE);\n" |
| 441 |
" }\n" |
| 442 |
"\\&\n" |
| 443 |
" for (;;) {\n" |
| 444 |
" dp = readdir(dirp);\n" |
| 445 |
" if (dp == NULL)\n" |
| 446 |
" break;\n" |
| 447 |
"\\&\n" |
| 448 |
" if (dp-E<gt>d_type == DT_LNK) {\n" |
| 449 |
" snprintf(path, sizeof(path), \"/proc/self/fd/%s\",\n" |
| 450 |
" dp-E<gt>d_name);\n" |
| 451 |
"\\&\n" |
| 452 |
" len = readlink(path, target, sizeof(target));\n" |
| 453 |
" printf(\"%s ==E<gt> %.*s\\[rs]n\", path, (int) len, target);\n" |
| 454 |
" }\n" |
| 455 |
" }\n" |
| 456 |
"\\&\n" |
| 457 |
" closedir(dirp);\n" |
| 458 |
"}\n" |
| 459 |
"\\&\n" |
| 460 |
"int\n" |
| 461 |
"main(int argc, char *argv[])\n" |
| 462 |
"{\n" |
| 463 |
" int fd;\n" |
| 464 |
"\\&\n" |
| 465 |
" for (size_t j = 1; j E<lt> argc; j++) {\n" |
| 466 |
" fd = open(argv[j], O_RDONLY);\n" |
| 467 |
" if (fd == -1) {\n" |
| 468 |
" perror(argv[j]);\n" |
| 469 |
" exit(EXIT_FAILURE);\n" |
| 470 |
" }\n" |
| 471 |
" printf(\"%s opened as FD %d\\[rs]n\", argv[j], fd);\n" |
| 472 |
" }\n" |
| 473 |
"\\&\n" |
| 474 |
" show_fds();\n" |
| 475 |
"\\&\n" |
| 476 |
" printf(\"========= About to call close_range() =======\\[rs]n\");\n" |
| 477 |
"\\&\n" |
| 478 |
" if (close_range(3, \\[ti]0U, 0) == -1) {\n" |
| 479 |
" perror(\"close_range\");\n" |
| 480 |
" exit(EXIT_FAILURE);\n" |
| 481 |
" }\n" |
| 482 |
"\\&\n" |
| 483 |
" show_fds();\n" |
| 484 |
" exit(EXIT_FAILURE);\n" |
| 485 |
"}\n" |
| 486 |
msgstr "" |
| 487 |
|
| 488 |
#. SRC END |
| 489 |
#. type: SH |
| 490 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 491 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 492 |
#, no-wrap |
| 493 |
msgid "SEE ALSO" |
| 494 |
msgstr "" |
| 495 |
|
| 496 |
#. type: Plain text |
| 497 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 498 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 499 |
msgid "B<close>(2)" |
| 500 |
msgstr "" |
| 501 |
|
| 502 |
#. type: TH |
| 503 |
#: debian-trixie |
| 504 |
#, no-wrap |
| 505 |
msgid "2024-06-15" |
| 506 |
msgstr "" |
| 507 |
|
| 508 |
#. type: TH |
| 509 |
#: debian-trixie |
| 510 |
#, no-wrap |
| 511 |
msgid "Linux man-pages 6.9.1" |
| 512 |
msgstr "" |
| 513 |
|
| 514 |
#. type: Plain text |
| 515 |
#: debian-trixie |
| 516 |
msgid "Standard C library (I<libc>, I<-lc>)" |
| 517 |
msgstr "" |
| 518 |
|
| 519 |
#. type: SS |
| 520 |
#: debian-trixie fedora-44 fedora-rawhide |
| 521 |
#, no-wrap |
| 522 |
msgid "Closing files on exec" |
| 523 |
msgstr "" |
| 524 |
|
| 525 |
#. type: Plain text |
| 526 |
#: debian-trixie fedora-44 fedora-rawhide |
| 527 |
#, no-wrap |
| 528 |
msgid "" |
| 529 |
"$ B<touch /tmp/a /tmp/b /tmp/c>\n" |
| 530 |
"$ B<./a.out /tmp/a /tmp/b /tmp/c>\n" |
| 531 |
"/tmp/a opened as FD 3\n" |
| 532 |
"/tmp/b opened as FD 4\n" |
| 533 |
"/tmp/c opened as FD 5\n" |
| 534 |
"/proc/self/fd/0 ==E<gt> /dev/pts/1\n" |
| 535 |
"/proc/self/fd/1 ==E<gt> /dev/pts/1\n" |
| 536 |
"/proc/self/fd/2 ==E<gt> /dev/pts/1\n" |
| 537 |
"/proc/self/fd/3 ==E<gt> /tmp/a\n" |
| 538 |
"/proc/self/fd/4 ==E<gt> /tmp/b\n" |
| 539 |
"/proc/self/fd/5 ==E<gt> /tmp/b\n" |
| 540 |
"/proc/self/fd/6 ==E<gt> /proc/9005/fd\n" |
| 541 |
"========= About to call close_range() =======\n" |
| 542 |
"/proc/self/fd/0 ==E<gt> /dev/pts/1\n" |
| 543 |
"/proc/self/fd/1 ==E<gt> /dev/pts/1\n" |
| 544 |
"/proc/self/fd/2 ==E<gt> /dev/pts/1\n" |
| 545 |
"/proc/self/fd/3 ==E<gt> /proc/9005/fd\n" |
| 546 |
msgstr "" |
| 547 |
|
| 548 |
#. type: TH |
| 549 |
#: fedora-44 fedora-rawhide |
| 550 |
#, no-wrap |
| 551 |
msgid "2024-07-23" |
| 552 |
msgstr "" |
| 553 |
|
| 554 |
#. type: TH |
| 555 |
#: fedora-44 fedora-rawhide |
| 556 |
#, no-wrap |
| 557 |
msgid "Linux man-pages 6.13" |
| 558 |
msgstr "" |
| 559 |
|
| 560 |
#. type: TH |
| 561 |
#: mageia-cauldron |
| 562 |
#, no-wrap |
| 563 |
msgid "Linux man-pages 6.17" |
| 564 |
msgstr "" |
| 565 |
|
| 566 |
#. type: TH |
| 567 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 568 |
#, no-wrap |
| 569 |
msgid "Linux man-pages (unreleased)" |
| 570 |
msgstr "" |