diff options
Diffstat (limited to 'libc-top-half/musl/src/legacy/ulimit.c')
-rw-r--r-- | libc-top-half/musl/src/legacy/ulimit.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/legacy/ulimit.c b/libc-top-half/musl/src/legacy/ulimit.c new file mode 100644 index 0000000..1f59e8e --- /dev/null +++ b/libc-top-half/musl/src/legacy/ulimit.c @@ -0,0 +1,19 @@ +#include <sys/resource.h> +#include <ulimit.h> +#include <stdarg.h> + +long ulimit(int cmd, ...) +{ + struct rlimit rl; + getrlimit(RLIMIT_FSIZE, &rl); + if (cmd == UL_SETFSIZE) { + long val; + va_list ap; + va_start(ap, cmd); + val = va_arg(ap, long); + va_end(ap); + rl.rlim_cur = 512ULL * val; + if (setrlimit(RLIMIT_FSIZE, &rl)) return -1; + } + return rl.rlim_cur / 512; +} |