RCTL_ADD_RULE(2)
π RCTL_ADD_RULE(2) π
ok so bestie, welcome to the System Calls Manual β this is the page for the rctl family of syscalls, aka the resource limits database crew. buckle up π
β¨ NAME β¨
rctl_add_rule, rctl_get_limits, rctl_get_racct, rctl_get_rules, rctl_remove_rule β manipulate and query the resource limits database π
π LIBRARY π
Standard C Library (libc, -lc) β the classic, the icon, the moment π
πΈ SYNOPSIS πΈ
#include <sys/rctl.h>
int
rctl_add_rule(const char *inbufp, size_t inbuflen, char *outbufp,
size_t outbuflen);
int
rctl_get_limits(const char *inbufp, size_t inbuflen, char *outbufp,
size_t outbuflen);
int
rctl_get_racct(const char *inbufp, size_t inbuflen, char *outbufp,
size_t outbuflen);
int
rctl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp,
size_t outbuflen);
int
rctl_remove_rule(const char *inbufp, size_t inbuflen, char *outbufp,
size_t outbuflen);
π¦ DESCRIPTION π¦
so these system calls are the ones you use to manipulate and query the resource limits database. for literally all of them, inbuflen is the length of the buffer that inbufp points at, and outbuflen is the length of the buffer that outbufp points at. simple as that, no cap π
rctl_add_rule()β adds the rule pointed to byinbufpto the resource limits database. theoutbufpandoutbuflenargs are just... sitting there, unused, not invited to the party π. rule format is the one described inrctl(8), except for the little exceptions we spill in the βRULES AND FILTERSβ section below.rctl_get_limits()β returns inoutbufpa comma-separated list of rules that apply to the process matching the filter you put ininbufp. and this includes rules where the subject is the process itself, plus rules with a different subject (like user or loginclass) that still apply to that process. it's giving "everyone who has a say in your life" energy ngl π«Άrctl_get_racct()β returns resource usage info for a given subject. you specify that subject by passing a filter ininbufp. filter syntax is as described inrctl(8), with the exceptions noted in βRULES AND FILTERSβ. what comes back inoutbufpis a comma-separated list of resources and how much of each the specified subject has used. each resource and amount is formatted as"resource=amount"β exactly like that,=and everything β¨rctl_get_rules()β returns inoutbufpa comma-separated list of rules from the resource limits database that match the filter passed ininbufp. filter syntax again = as described inrctl(8), exceptions in βRULES AND FILTERSβ. and ooh, fun fact: you can pass a filter of::to get ALL the rules back. main character behavior honestly πrctl_remove_rule()β removes all rules matching the filter passed ininbufpfrom the resource limits database. filter syntax =rctl(8), exceptions in βRULES AND FILTERSβ.outbufpandoutbuflen? unused, ignored, not relevant, bye π
π RULES AND FILTERS π
ok this section is lowkey important so pay attention bestie. it explains how the rule and filter format from rctl(8) is different from the format you pass straight to the system calls themselves. the rctl tool is out here doing extra favors for you that the syscalls simply do not do. so when you're using the system call:
- The subject must be fully specified. for example, abbreviating βuserβ to βuβ is not acceptable. spell it out, no shortcuts π
- User and group IDs must be numeric. for example, βrootβ must be expressed as β0β. the syscall does not know who root is, it knows
0π’ - Units are not permitted on resource amounts. for example, a quantity of 1024 bytes must be expressed as β1024β and not β1kβ. no cute little suffixes allowed, sorry π₯²
β RETURN VALUES β
when everything goes right, the value 0 is returned πβ¨. otherwise the value -1 comes back and the global variable errno gets set to tell you what went wrong. it's giving "we need to talk" energy π
π ERRORS π
the rctl system calls may fail if:
[ENOSYS]β RACCT/RCTL support is not present in the kernel, or thekern.racct.enablesysctl is0. the feature literally isn't home rn π[EINVAL]β the rule or filter passed ininbufpis invalid. something you typed is not it, bestie π¬[EPERM]β user has insufficient privileges to carry out the requested operation. you do not have the clearance for this one, gatekept fr π[E2BIG]βinbufporoutbufpare too large. too much. overwhelming. overstimulated π[ESRCH]β no process matched the provided rule or filter. nobody came to the function π[ENAMETOOLONG]β the loginclass or jail name specified is too long. it's a lot of letters and the kernel said no π«[ERANGE]β the rule amount is outside of the allowable range, oroutbufpis too small. either the number is out of pocket or your buffer is tiny π₯²[EOPNOTSUPP]β the requested operation is not supported for the given rule or filter. it's just not the vibe for that particular combo β[EFAULT]βinbufporoutbufprefer to invalid addresses. those pointers are pointing into the void π
π SEE ALSO π
rctl(8)β go read it, it's the whole other half of this story π
π HISTORY π
The rctl family of system calls appeared in FreeBSD 9.0. a classic, an icon, a legend, periodt π
π«Ά AUTHORS π«Ά
The rctl system calls were developed by Edward Tomasz Napierala <trasz@FreeBSD.org> under sponsorship from the FreeBSD Foundation. This manual page was written by Eric Badger <badger@FreeBSD.org>. absolute legends, both of them, no notes πβ¨
and that's the whole page bestie! go forth and limit your resources responsibly ππ
this little love letter came to you from the Debian edition, dated September 14, 2016 β RCTL_ADD_RULE(2), signing off π¦πΈ
π¦ 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) 2016 Eric Badger
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms