sys_resource.h(0P)
๐ sys/resource.h โ bestie's guide to XSI resource ops ๐
okay so first things first: this is a page from the POSIX Programmer's Manual (0P, she's certified, she's iconic), and the header file we're stanning is sys/resource.h โ the place where all your definitions for XSI resource operations live. ๐
โ ๏ธ real talk bestie: the Linux implementation of this interface may differ, so pls consult the corresponding Linux manual page for details of Linux behavior. Also? The interface might just... not be implemented on Linux at all. ๐
โจ SYNOPSIS โจ
#include <sys/resource.h>
๐ DESCRIPTION ๐
So the <sys/resource.h> header is gonna define these symbolic constants as possible values for the which argument of getpriority() and setpriority(). Like, which thing are we even talking about here:
PRIO_PROCESSโ says the who argument is a process ID. ๐PRIO_PGRPโ says the who argument is a process group ID.PRIO_USERโ says the who argument is a user ID.
๐ฆ the typedef, she's serving
The header also defines this type through typedef:
rlim_tโ an unsigned integer type used for limit values. That's the one, no cap.
โญ constants you can use in #if โญ
Next up, these symbolic constants, and their values are suitable for use in #if preprocessing directives. Periodt:
RLIM_INFINITYโ a value ofrlim_tindicating no limit. Live your truth, no limits. ๐ฆ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 lil plot twist: on implementations where all resource limits are representable in an object of type rlim_t, then RLIM_SAVED_MAX and RLIM_SAVED_CUR need not be distinct from RLIM_INFINITY. So don't @ them if they're the same. ๐ญ
๐ธ getrusage() vibes: the who parameter
The header defines these as possible values of the who parameter of getrusage():
RUSAGE_SELFโ returns info about the current process. main character energy fr.RUSAGE_CHILDRENโ returns info about the children of the current process. the kids!! ๐ซถ
๐ the rlimit structure
The header defines the rlimit structure, which shall include at least these members:
rlim_t rlim_cur The current (soft) limit.
rlim_t rlim_max The hard limit.
๐ the rusage structure
And the header defines the rusage structure, which shall include at least these members:
struct timeval ru_utime User time used.
struct timeval ru_stime System time used.
Oh and the header also defines the timeval structure as described in <sys/time.h>. Iconic crossover event. โจ
๐ฅ RLIMIT constants โ possible values for the resource argument ๐ฅ
The header defines these 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 (and maybe macros, she's flexible)
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided. Code is code, don't touch it:
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 *);
๐ one more typedef moment
The <sys/resource.h> header defines the id_t type through typedef, as described in <sys/types.h>.
And heads up: including the <sys/resource.h> header may also make visible all symbols from <sys/time.h>. Surprise bonus content. ๐
๐ note: the following sections are informative. Not normative, just chatting.
๐ฌ APPLICATION USAGE
None. Literally nothing. Empty. A whole mood. ๐
๐ง RATIONALE
None. Again. She said "no thoughts, head empty." ๐ญ
๐ฎ FUTURE DIRECTIONS
None. The future is undefined and honestly? same. ๐
๐ SEE ALSO
<sys_time.h><sys_types.h>
The System Interfaces volume of POSIX.1โ2017, plus:
getpriority()getrlimit()getrusage()
๐ COPYRIGHT
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 .
and that's the whole page bestie!! this lil baddie dropped back in 2017, courtesy of IEEE / The Open Group, and she's filed under sys_resource.h(0P). go set some limits, know your rusage, and slay responsibly. ๐โจ๐
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms