glibc/sysdeps/unix/sysv/linux/sparc
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
..
bits y2038: Add __USE_TIME_BITS64 support for socket-constants.h 2021-06-15 10:42:11 -03:00
sparc32 io: Add closefrom [BZ #10353] 2021-07-08 14:08:14 -03:00
sparc64 io: Add closefrom [BZ #10353] 2021-07-08 14:08:14 -03:00
sys
Implies
Makefile nptl: Remove remaining code from libpthread 2021-05-21 22:35:01 +02:00
Versions Linux: Move aio_cancel, aio_cancel64 into libc 2021-06-25 11:48:46 +02:00
a.out.h
aio_cancel.c Linux: Move aio_cancel, aio_cancel64 into libc 2021-06-25 11:48:46 +02:00
configure
configure.ac
dl-cache.h
errlist-compat.c
getrlimit64.c
getshmlba.c
kernel-features.h linux: Consolidate Linux setsockopt implementation 2021-07-06 11:45:35 -03:00
kernel_sigaction.h
kernel_termios.h
ldd-rewrite.sed
librt-compat.c Linux: Move timer_settime, __timer_settime64 from librt to libc 2021-06-28 09:51:01 +02:00
profil-counter.h
readelflib.c
rt-sysdep.c
socket-constants-time64.h linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} 2021-06-15 10:42:06 -03:00
struct_kernel_shmid64_ds.h
sysdep.c
sysdep.h
xstatver.h