RCTL_ADD_RULE(2)
π RCTL_ADD_RULE(2) β the resource-limits girlies π
okay so bestie, buckle up, this is the System Calls Manual page for the whole rctl family and it lives in section 2 (system calls, not commands, iykyk) β¨
πΈ NAME
rctl_add_rule, rctl_get_limits, rctl_get_racct, rctl_get_rules, rctl_remove_rule β literally the whole squad that manipulates and queries the resource limits database π
π¦ LIBRARY
Standard C Library (libc, -lc) π«Ά
β 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 β¨
okay so these system calls are your main characters for manipulating and querying the resource limits database π for all of them, inbuflen is the length of the buffer that inbufp points to, and outbuflen is the length of the buffer that outbufp points to. no cap, that's the whole buffer deal π
rctl_add_rule()β adds the rule thatinbufppoints to into the resource limits database π theoutbufpandoutbuflenarguments are unused (they're just... there, vibing π). rule format is exactly as described inrctl(8), except for the exceptions noted down in the βRULES AND FILTERSβ section below, so don't skip it bestie.rctl_get_limits()β hands you back, inoutbufp, a comma-separated list of rules that apply to the process matching the filter you specified ininbufpπ and yes, this includes rules whose subject is the process itself and rules with a different subject (likeuserorloginclass) that still apply to that process. it's giving "everyone who has beef with you, listed" πrctl_get_racct()β returns resource usage info for a given subject π you specify that subject by passing a filter ininbufp, and the filter syntax is as described inrctl(8)except for those exceptions in βRULES AND FILTERSβ. you get back, inoutbufp, 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"β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)with the exceptions in βRULES AND FILTERSβ. and here's the iconic trick: pass a filter of::to return all the rules πrctl_remove_rule()β removes every rule matching the filter passed ininbufpfrom the resource limits database π§ filter syntax as described inrctl(8), exceptions in βRULES AND FILTERSβ, andoutbufpandoutbuflenare unused. girl, it's a delete, what did you expect in the output buffer π
π RULES AND FILTERS
this section is the whole "here's what's different" moment, because the rule and filter format described in rctl(8) is not identical to the format you pass into the system calls themselves. the rctl tool gives you several conveniences that the system calls simply do not π
so when you're using the system call:
- the subject must be fully specified. for example, abbreviating β
userβ to βuβ is not acceptable π ββοΈ - user and group IDs must be numeric. for example, β
rootβ must be expressed as β0β π«Ά - units are not permitted on resource amounts. for example, a quantity of 1024 bytes must be expressed as β
1024β and not β1kβ π
π RETURN VALUES
upon successful completion, the value 0 is returned π₯³ otherwise the value -1 is returned and the global variable errno is set to indicate the error. classic.
π ERRORS
the rctl system calls may fail if:
[ENOSYS]β RACCT/RCTL support is not present in the kernel, or thekern.racct.enablesysctl is0. it's giving "feature not found, go home" π[EINVAL]β the rule or filter passed ininbufpis invalid.[EPERM]β user has insufficient privileges to carry out the requested operation. no keys to the kingdom for you π[E2BIG]βinbufporoutbufpare too large.[ESRCH]β no process matched the provided rule or filter.[ENAMETOOLONG]β theloginclassorjailname specified is too long. bestie that name is a whole paragraph π[ERANGE]β the rule amount is outside of the allowable range, oroutbufpis too small.[EOPNOTSUPP]β the requested operation is not supported for the given rule or filter.[EFAULT]βinbufporoutbufprefer to invalid addresses.
π₯ SEE ALSO
rctl(8) β go read it, it's the vibe source for all the rule formats up there β
π HISTORY
the rctl family of system calls appeared in FreeBSD 9.0. vintage, but make it iconic.
π§ AUTHORS
the rctl system calls were developed by Edward Tomasz Napierala <trasz@FreeBSD.org> under sponsorship from the FreeBSD Foundation π«Ά and this manual page was written by Eric Badger <badger@FreeBSD.org>. absolute legends, both of them π
okay that's the whole page, no cap, every flag and every errno accounted for π
and that's a wrap bestie!! this page is from Debian, dated September 14, 2016, and it's the RCTL_ADD_RULE(2) page β slay, go set some resource limits, periodt β¨π
π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2016 Eric Badger
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms