LIM_CUR(9)

πŸ“¦ in nixpkgs unstable

okay so welcome to LIM_CUR(9) from the Kernel Developer's Manual, bestie πŸ’– this is literally the resource limit interface, and we're gonna read it together, no cap.

🌸 NAME 🌸

lim_cur, lim_cur_proc, lim_fork, lim_free, lim_read_enter, lim_read_leave β€” Resource limit interface ✨

✨ SYNOPSIS ✨

#include <sys/types.h>
#include <sys/resourcevar.h>

rlim_t
lim_cur(int which);

rlim_t
lim_cur_proc(struct proc *p, int which);

struct plimit *
lim_fork(struct process *parent, struct process *child);

void
lim_free(struct plimit *limit);

struct plimit *
lim_read_enter();

void
lim_read_leave(struct plimit *limit);

πŸ’– DESCRIPTION πŸ’–

The resource limit interface gives you read access to the resource limits of the process. Iconic behavior, honestly 🫢

lim_cur() returns the value of limit which of the current process. The which can take one of these values, and you're gonna want to keep them exactly as written:

#define RLIMIT_CPU      0       /* cpu time in milliseconds */
#define RLIMIT_FSIZE    1       /* maximum file size */
#define RLIMIT_DATA     2       /* data size */
#define RLIMIT_STACK    3       /* stack size */
#define RLIMIT_CORE     4       /* core file size */
#define RLIMIT_RSS      5       /* resident set size */
#define RLIMIT_MEMLOCK  6       /* locked-in-memory address space */
#define RLIMIT_NPROC    7       /* number of processes */
#define RLIMIT_NOFILE   8       /* number of open files */

lim_cur_proc() is like lim_cur() but returns the value of limit which of thread p. yes bestie, thread p, that's what it says πŸ’…

lim_read_enter() begins read access to the current process' resource limit structure.

lim_read_leave() finishes read access to the resource limit structure.

🚨 okay so this part matters: sections denoted by lim_read_enter() and lim_read_leave() cannot nest. Using lim_cur() inside the read section is not allowed because the function uses lim_read_enter() and lim_read_leave() internally. do not try it, bestie 😭

lim_free() releases the reference limit.

lim_fork() makes the process child share the resource limits of process parent. sharing is caring, periodt πŸ’–

πŸ¦‹ CONTEXT πŸ¦‹

lim_cur(), lim_cur_proc(), lim_fork(), lim_free(), lim_read_enter() and lim_read_leave() can be called during autoconf, or from process context. slay ✨

πŸŽ€ RETURN VALUES πŸŽ€

  • lim_cur() and lim_cur_proc() return the value of the given resource limit.
  • lim_read_enter() returns a read reference to the current process' resource limits.

mwah πŸ’‹ β€” this cutie came from Debian, dated June 21, 2019, and yes bestie, it was the LIM_CUR(9) manual page. periodt πŸŽ€

πŸ“¦ where this page comes from