/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ #pragma ident "%Z%%M% %I% %E% SMI" /* from UCB 4.2 83/06/20 */ /* * (Almost) backwards compatible vlimit. */ #include #include #include /* LIM_NORAISE is not emulated */ #define LIM_NORAISE 0 /* if <> 0, can't raise limits */ #define LIM_CPU 1 /* max secs cpu time */ #define LIM_FSIZE 2 /* max size of file created */ #define LIM_DATA 3 /* max growth of data space */ #define LIM_STACK 4 /* max growth of stack */ #define LIM_CORE 5 /* max size of ``core'' file */ #define LIM_MAXRSS 6 /* max desired data+stack core usage */ #define NLIMITS 6 vlimit(limit, value) int limit, value; { struct rlimit rlim; if (limit <= 0 || limit > NLIMITS) return (EINVAL); if (value == -1) { if (getrlimit(limit - 1, &rlim) < 0) return (-1); return (rlim.rlim_cur); } rlim.rlim_cur = value; rlim.rlim_max = RLIM_INFINITY; return (setrlimit(limit - 1, &rlim)); }