glibc/sysdeps/unix/sysv/linux/x86_64
Adhemerval Zanella 607449506f io: Add closefrom [BZ #10353]
The function closes all open file descriptors greater than or equal to
input argument.  Negative values are clamped to 0, i.e, it will close
all file descriptors.

As indicated by the bug report, this is a common symbol provided by
different systems (Solaris, OpenBSD, NetBSD, FreeBSD) and, although
its has inherent issues with not taking in consideration internal libc
file descriptors (such as syslog), this is also a common feature used
in multiple projects [1][2][3][4][5].

The Linux fallback implementation iterates over /proc and close all
file descriptors sequentially.  Although it was raised the questioning
whether getdents on /proc/self/fd might return disjointed entries
when file descriptor are closed; it does not seems the case on my
testing on multiple kernel (v4.18, v5.4, v5.9) and the same strategy
is used on different projects [1][2][3][5].

Also, the interface is set a fail-safe meaning that a failure in the
fallback results in a process abort.

Checked on x86_64-linux-gnu and i686-linux-gnu on kernel 5.11 and 4.15.

[1] 5238e95759/src/basic/fd-util.c (L217)
[2] ddf4b77e11/src/lxc/start.c (L236)
[3] 9e4f2f3a6b/Modules/_posixsubprocess.c (L220)
[4] 5f47c0613e/src/libstd/sys/unix/process2.rs (L303-L308)
[5] https://github.com/openjdk/jdk/blob/master/src/java.base/unix/native/libjava/childproc.c#L82
2021-07-08 14:08:14 -03:00
..
64 io: Add closefrom [BZ #10353] 2021-07-08 14:08:14 -03:00
x32 io: Add closefrom [BZ #10353] 2021-07-08 14:08:14 -03:00
____longjmp_chk.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
__start_context.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
clone.S x86-64: Align child stack to 16 bytes [BZ #27902] 2021-05-31 12:03:36 -07:00
configure Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
configure.ac Move architecture cases out of sysdeps/unix/sysv/linux/configure.ac. 2014-06-24 20:53:03 +00:00
dl-cache.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
dl-procinfo.c Add _dl_x86_cpu_features to rtld_global 2015-08-13 03:41:22 -07:00
dl-procinfo.h x86: Set dl_platform and dl_hwcap from CPU features [BZ #21391] 2017-05-03 13:44:35 -07:00
getcontext.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Implies NPTL is no longer an add-on! 2014-07-07 09:29:06 -07:00
kernel-features.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
ldconfig.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
ldd-rewrite.sed
libc_sigaction.c signal: Add __libc_sigaction 2021-03-18 15:54:39 -03:00
libmvec.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
makecontext.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Makefile ldconfig/x86: Store ISA level in cache and aux cache 2021-01-13 05:51:17 -08:00
register-dump.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
setcontext.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sigaltstack-offsets.sym
sigcontextinfo.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
swapcontext.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
syscall.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
syscalls.list linux: Consolidate Linux setsockopt implementation 2021-07-06 11:45:35 -03:00
sysdep.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sysdep.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-glibc-hwcaps-2.c x86-64: Update tst-glibc-hwcaps-2.c for x86-64 baseline 2021-01-22 09:37:44 -08:00
ucontext_i.sym x86-64/CET: Extend ucontext_t to save shadow stack 2018-07-25 06:37:31 -07:00
Versions Linux: Move timer_settime, __timer_settime64 from librt to libc 2021-06-28 09:51:01 +02:00
vfork.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
x86-64-isa-level-VALUE.c ldconfig/x86: Store ISA level in cache and aux cache 2021-01-13 05:51:17 -08:00