CLOSEFROM(2)
β¨ NAME β¨
closefrom, close_range β delete open file descriptors π
okay so bestie, this is the manual page for closefrom(2) and close_range(2) β they're literally the "bye bye file descriptors" girlies πβ¨
π LIBRARY π
Standard C Library (libc, -lc) β she lives there, no cap π«Ά
π¦ SYNOPSIS π¦
#include <unistd.h>
void
closefrom(int lowfd);
int
close_range(u_int lowfd, u_int highfd, int flags);
πΈ DESCRIPTION πΈ
Okay so first up: closefrom() is a system call that 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 β¨ any errors encountered while closing file descriptors are ignored β she's unbothered, she's thriving, she does not care π
Then we have close_range(), which deletes all open file descriptors between lowfd and highfd inclusive, clamped to the range of open file descriptors. Same energy: any errors encountered while closing file descriptors are ignored, periodt π
The supported flags are:
CLOSE_RANGE_CLOEXECβ set the close-on-exec flag on descriptors in the range instead of closing them π₯CLOSE_RANGE_CLOFORKβ set the close-on-fork flag on descriptors in the range instead of closing them π
β RETURN VALUES β
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. (Yes bestie, <italic>errno</italic> is literally the main character of error reporting π)
π ERRORS π
The close_range() system call will fail if:
[EINVAL]β the highfd argument is lower than the lowfd argument. not her getting the order wrong π[EINVAL]β an invalid flag was set. nope, not on the list, not today π
π SEE ALSO π
close(2)β the og, the blueprint, we stan π
π§ HISTORY π§
- The
closefrom()function first appeared in FreeBSD 8.0. - The
close_range()function first appeared in FreeBSD 12.2. - The
CLOSE_RANGE_CLOFORKflag appeared in FreeBSD 15.0.
okay that's the whole page bestie, hope it slayed π this little drop came from the Debian fam, dated October 27, 2025 β mwah, take care, and remember: close your fds before they close you π«Άβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 2009 Hudson River Trading LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms