feat(resource): rlimit/rusage/priority

This commit is contained in:
2026-09-05 22:55:20 -04:00
parent c4156efeff
commit 3ab43c7f10
8 changed files with 668 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/resource.h>
#include "../internal/syscall.h"
#if VLIBC_LEVEL_GE(2)
/*
* setrlimit/setrlimit64 (todo 31).
*
* The write side of the prlimit64 ABI: (pid = 0, resource,
* new_limit = &rlim, old_limit = NULL). struct rlimit is the kernel's
* struct rlimit64 layout on x86_64, so the record passes through without
* conversion; the kernel rejects a soft limit above the hard limit with
* EINVAL and a hard-limit raise without CAP_SYS_RESOURCE with EPERM.
*
* setrlimit64 is a name-only distinction on this architecture (rlim_t is
* already 64 bits); it exists as a separate exported symbol for LFS
* callers.
*/
int
setrlimit(int resource, const struct rlimit *rlim)
{
return syscall_ret(__syscall4(SYS_prlimit64, 0, (long)resource, (long)rlim, 0));
}
int
setrlimit64(int resource, const struct rlimit *rlim)
{
return setrlimit(resource, rlim);
}
#endif /* VLIBC_LEVEL_GE(2) */