CLOSEFROM(2)
π
CLOSEFROM β the closefrom and close_range system calls, bestie
okay so you know how file descriptors just... pile up?? like laundry but for your process?? yeah. this is the manual page for closefrom and close_range, and it's giving "spring cleaning but make it syscalls" π§Ήβ¨
π¦ NAME
closefrom, close_range β delete open file descriptors
no cap, that's literally the whole job. they delete open file descriptors. slay.
π LIBRARY
Standard C Library (libc, -lc)
β¨ SYNOPSIS
#include <unistd.h>
void
closefrom(int lowfd);
int
close_range(u_int lowfd, u_int highfd, int flags);
πΈ DESCRIPTION
okay so first up: the closefrom() system call deletes all open file descriptors greater than or equal to lowfd from the per-process object reference table. that's it. that's the whole vibe. and here's the chaotic part β any errors encountered while closing file descriptors are ignored. like, it does NOT care. it's just closing things and moving on with its life π
then we got close_range(), which is the glow-up version. it deletes all open file descriptors between lowfd and highfd inclusive, clamped to the range of open file descriptors. same energy as before: any errors encountered while closing file descriptors are ignored. and listen β there are currently no defined flags. zero. none. the flags slot is empty, it's a vibe check that nobody has passed yet π
π«Ά RETURN VALUES
when it eats, it eats: upon successful completion, close_range() returns a value of 0 π₯
otherwise, a value of -1 is returned and the global variable errno is set to indicate the error. so check your errno bestie, it's telling you something π
π ERRORS
the close_range() system call will fail if:
[EINVAL]β thehighfdargument is lower than thelowfdargument. girl. that's backwards. that range is invalid π«[EINVAL]β an invalid flag was set. (remember, there are currently no defined flags, so like... what are you even setting π)
π SEE ALSO
π HISTORY
the closefrom() function first appeared in FreeBSD 8.0. a legend was born, periodt π
and that's the whole page, bestie!! this one came from the <strong>Debian</strong> manual pages, dated <strong>April 12, 2020</strong>, and it's filed under <strong>CLOSEFROM(2)</strong> π go close some file descriptors, you got this π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2009 Hudson River Trading LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms