sys_resource.h(7POSIX)
๐ sys_resource.h โ the POSIX page, but make it bestie ๐
okay so this is sys_resource.h from the POSIX Programmer's Manual (that's the 7POSIX section, for the uninitiated). come sit with me, we're gonna get through this together, it's literally so much shorter than it looks ๐ซถ
๐ธ PROLOG ๐ธ
bestie. real talk. this manual page is part of the POSIX Programmer's Manual, right? and the tea is: the Linux implementation of this interface may differ โ so if you're on Linux, go consult the corresponding Linux manual page for the details of Linux behavior. OR. plot twist. the interface may not be implemented on Linux at all. ๐ so like. vibe check your platform first, fr fr.
โจ NAME โจ
sys/resource.h โ definitions for XSI resource operations ๐
๐ SYNOPSIS ๐
#include <sys/resource.h>
that's it. that's the whole synopsis. iconic.
๐ DESCRIPTION ๐
okay so here's what this header is gonna do for you. it's a header, it's got lore, let's go section by section because there's a lot of little constants and they all matter.
the which girls (for getpriority() and setpriority()) ๐
<sys/resource.h> shall define these symbolic constants as possible values of the which argument of getpriority() and setpriority():
PRIO_PROCESSโ says thewhoargument is a process ID.PRIO_PGRPโ says thewhoargument is a process group ID.PRIO_USERโ says thewhoargument is a user ID.
the typedef moment ๐ฆ
the header shall define this type through typedef:
rlim_tโ an unsigned integer type used for limit values. she's the limit girlie.
the #if-safe constants โญ
these symbolic constants get defined, and their values shall be suitable for use in #if preprocessing directives (yes, in the preprocessor, not just at runtime โ that's the whole point):
RLIM_INFINITYโ a value ofrlim_tindicating no limit.RLIM_SAVED_MAXโ a value of typerlim_tindicating an unrepresentable saved hard limit.RLIM_SAVED_CURโ a value of typerlim_tindicating an unrepresentable saved soft limit.
and here's the cute little footnote: on implementations where all resource limits are representable in an object of type rlim_t, RLIM_SAVED_MAX and RLIM_SAVED_CUR need not be distinct from RLIM_INFINITY. so don't be out here assuming they're different, okay? ๐
the who girls (for getrusage()) ๐
<sys/resource.h> shall define these symbolic constants as possible values of the who parameter of getrusage():
RUSAGE_SELFโ returns information about the current process.RUSAGE_CHILDRENโ returns information about children of the current process.
struct rlimit ๐ง
the header shall define the rlimit structure, and it shall include at least these members:
rlim_t rlim_cur /* The current (soft) limit. */
rlim_t rlim_max /* The hard limit. */
struct rusage ๐
the header shall define the rusage structure, and it shall include at least these members:
struct timeval ru_utime /* User time used. */
struct timeval ru_stime /* System time used. */
and where does struct timeval come from? <sys/resource.h> shall define the timeval structure as described in <sys/time.h>. no reinventing the wheel here, bestie.
the resource constants (for getrlimit() and setrlimit()) ๐ฅ
<sys/resource.h> shall define these symbolic constants as possible values for the resource argument of getrlimit() and setrlimit():
RLIMIT_COREโ limit on size of core file.RLIMIT_CPUโ limit on CPU time per process.RLIMIT_DATAโ limit on data segment size.RLIMIT_FSIZEโ limit on file size.RLIMIT_NOFILEโ limit on number of open files.RLIMIT_STACKโ limit on stack size.RLIMIT_ASโ limit on address space size.
the functions ๐
these shall be declared as functions, and they may also be defined as macros. function prototypes shall be provided:
int getpriority(int, id_t);
int getrlimit(int, struct rlimit *);
int getrusage(int, struct rusage *);
int setpriority(int, id_t, int);
int setrlimit(int, const struct rlimit *);
and one more typedef ๐ธ
<sys/resource.h> shall define the id_t type through typedef, as described in <sys/types.h>.
sneaky bonus symbols ๐
inclusion of the <sys/resource.h> header may also make visible all symbols from <sys/time.h>. so like, free real estate, maybe. "may." don't come for me.
heads up: the following sections are informative โ they're not normative, they're just vibes and context. ๐ซ
๐ซถ APPLICATION USAGE ๐ซถ
None. nothing. empty. the void. and honestly? respect. ๐
๐ญ RATIONALE ๐ญ
None. again โ nothing. no thoughts, head empty, and it's serving. โจ
๐ฎ FUTURE DIRECTIONS ๐ฎ
None. the future is bright and completely undefined for this one. slay. ๐
๐ SEE ALSO ๐
<sys_time.h><sys_types.h>- the System Interfaces volume of POSIX.1โ2017:
getpriority(),getrlimit(),getrusage()
go read those, bestie, that's where the actual behavior lives. iykyk ๐ฆ
๐ COPYRIGHT ๐
okay so legally I have to tell you this, and I'm gonna tell you this properly:
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
not me having to cite my sources like a good academic girlie ๐ โ this page came from IEEE/The Open Group, dated 2017, and it lives at sys_resource.h(7POSIX). mwah. take care of her. ๐๐โจ
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms