go-linux

Resource limit design

Part of the accepted-design index.

Use the maintained x/sys Prlimit binding. It already carries the unsigned 64-bit ABI and submits both limit pointers in one call. Reading before a separate update would allow another writer to invalidate the returned previous limit. Linux validates the resource and the requested pair and owns permission and admission checks. Linux 7.0 implementation.

The package-level operations explicitly target the current process. A positive ProcessID addresses another process with the kernel’s numeric PID semantics. A pidfd cannot be passed to prlimit64. A cooperating child can block while its supervisor applies limits, keeping lifetime and startup policy in the application.

The maintained binding integrates intentional self-updates of RLIMIT_NOFILE with Go’s normal child inheritance. A raw syscall would bypass Go’s bookkeeping for restoring its pre-startup soft limit at exec. The package adds no startup limit adjustments. Go syscall implementation.