setrlimit
Setrlimit is a POSIX-compatible API that sets resource limits for the calling process. It updates the soft limit (rlim_cur) and hard limit (rlim_max) for a specified resource, using a struct rlimit. The rlimit structure contains rlim_cur and rlim_max, both of type rlim_t. The resource parameter selects which limit to adjust, with common examples including RLIMIT_CPU (CPU time), RLIMIT_FSIZE (file size), RLIMIT_DATA (data segment size), RLIMIT_STACK (stack size), RLIMIT_CORE (core file size), RLIMIT_AS (address space), RLIMIT_NOFILE (number of open files), RLIMIT_NPROC (number of processes), and RLIMIT_MEMLOCK or RLIMIT_RSS on some systems.
Operation and effects: The soft limit is the enforcement threshold seen by the kernel at runtime, while
Behavior on limit breach: If a process attempts to exceed a limit, the kernel may take an
Usage notes: setrlimit is declared in header <sys/resource.h> and is commonly used for resource protection, sandboxing,