1.\" $NetBSD: ulimit.3,v 1.6 2002/10/01 16:59:48 wiz Exp $ 2.\" 3.\" Copyright (c) 1999 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Klaus Klein. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd September 13, 1999 38.Dt ULIMIT 3 39.Os 40.Sh NAME 41.Nm ulimit 42.Nd get and set process limits 43.Sh LIBRARY 44.Lb libc 45.Sh SYNOPSIS 46.Fd #include \*[Lt]ulimit.h\*[Gt] 47.Ft long int 48.Fn ulimit "int cmd" ... 49.Sh DESCRIPTION 50The 51.Fn ulimit 52function provides a method to query or alter resource limits of the calling 53process. 54The method to be performed is specified by the 55.Fa cmd 56argument; possible values are: 57.Bl -tag -width UL_GETFSIZEXX 58.It Li UL_GETFSIZE 59Return the soft file size limit of the process. 60The value returned is in units of 512-byte blocks. 61If the result cannot be represented in an object of type 62.Fa long int , 63the result is unspecified. 64.It Li UL_SETFSIZE 65Set the hard and soft file size limits of the process to the value of the 66second argument passed, which is in units of 512-byte blocks, and which is 67expected to be of type 68.Fa long int . 69The new file size limit of the process is returned. 70Any process may decrease the limit, but raising it is only permitted if 71the caller is the super-user. 72.El 73.Pp 74If successful, the 75.Fn ulimit 76function will not change the setting of 77.Va errno . 78.Pp 79The 80.Fn ulimit 81function is an obsolete interface; applications are encouraged to use 82.Xr getrlimit 2 83and 84.Xr setrlimit 2 85instead. 86.Sh RETURN VALUES 87If successful, the 88.Fn ulimit 89function returns the value of the requested limit. 90Otherwise, it returns \-1, sets 91.Va errno 92to indicate an error, and the limit is not changed. 93Therefore, to detect an error condition applications should set 94.Va errno 95to 0, call 96.Fn ulimit , 97and check if \-1 is returned and 98.Va errno 99is non-zero. 100.Sh ERRORS 101The 102.Fn ulimit 103function will fail if: 104.Bl -tag -width Er 105.It Bq Er EINVAL 106The 107.Fa cmd 108argument is not valid. 109.It Bq Er EPERM 110It was attempted to increase a limit, and the caller is not the super-user. 111.El 112.Sh SEE ALSO 113.Xr getrlimit 2 , 114.Xr setrlimit 2 115.Sh STANDARDS 116The 117.Fn ulimit 118function conforms to 119.St -xsh5 . 120