|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: */ ! 6: ! 7: #if defined(LIBC_SCCS) && !defined(lint) ! 8: static char sccsid[] = "@(#)vlimit.c 5.2 (Berkeley) 3/9/86"; ! 9: #endif LIBC_SCCS and not lint ! 10: ! 11: /* ! 12: * (Almost) backwards compatible vlimit. ! 13: */ ! 14: #include <sys/time.h> ! 15: #include <sys/resource.h> ! 16: #include <errno.h> ! 17: ! 18: /* LIM_NORAISE is not emulated */ ! 19: #define LIM_NORAISE 0 /* if <> 0, can't raise limits */ ! 20: #define LIM_CPU 1 /* max secs cpu time */ ! 21: #define LIM_FSIZE 2 /* max size of file created */ ! 22: #define LIM_DATA 3 /* max growth of data space */ ! 23: #define LIM_STACK 4 /* max growth of stack */ ! 24: #define LIM_CORE 5 /* max size of ``core'' file */ ! 25: #define LIM_MAXRSS 6 /* max desired data+stack core usage */ ! 26: ! 27: #define NLIMITS 6 ! 28: ! 29: vlimit(limit, value) ! 30: int limit, value; ! 31: { ! 32: struct rlimit rlim; ! 33: ! 34: if (limit <= 0 || limit > NLIMITS) ! 35: return (EINVAL); ! 36: if (value == -1) { ! 37: if (getrlimit(limit - 1, &rlim) < 0) ! 38: return (-1); ! 39: return (rlim.rlim_cur); ! 40: } ! 41: rlim.rlim_cur = value; ! 42: rlim.rlim_max = RLIM_INFINITY; ! 43: return (setrlimit(limit - 1, &rlim)); ! 44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.