1.\" $NetBSD: ulimit.3,v 1.2 1999/10/11 11:03:27 kleink 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 <ulimit.h> 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. The method to be performed is specified by the 54.Fa cmd 55argument; possible values are: 56.Bl -tag -width UL_GETFSIZEXX 57.It Li UL_GETFSIZE 58Return the soft file size limit of the process. 59The value returned is in units of 512-byte blocks. 60If the result cannot be represented in an object of type 61.Fa long int , 62the result is unspecified. 63.It Li UL_SETFSIZE 64Set the hard and soft file size limits of the process to the value of the 65second argument passed, which is in units of 512-byte blocks, and which is 66expected to be of type 67.Fa long int . 68The new file size limit of the process is returned. 69Any process may decrease the limit, but raising it is only permitted if 70the caller is the super-user. 71.El 72.Pp 73If successful, the 74.Fn ulimit 75function will not change the setting of 76.Va errno . 77.Pp 78The 79.Fn ulimit 80function is an obsolete interface; applications are encouraged to use 81.Xr getrlimit 2 82and 83.Xr setrlimit 2 84instead. 85.Sh RETURN VALUE 86If successful, the 87.Fn ulimit 88function returns the value of the requested limit. 89Otherwise, it returns -1, sets 90.Va errno 91to indicate an error, and the limit is not changed. 92Therefore, to detect an error condition applications should set 93.Va errno 94to 0, call 95.Fn ulimit , 96and check if -1 is returned and 97.Va errno 98is non-zero. 99.Sh ERRORS 100The 101.Fn ulimit 102function will fail if: 103.Bl -tag -width Er 104.It Bq Er EINVAL 105The 106.Fa cmd 107argument is not valid. 108.It Bq Er EPERM 109It was attempted to increase a limit, and the caller is not the super-user. 110.El 111.Sh SEE ALSO 112.Xr getrlimit 2 , 113.Xr setrlimit 2 114.Sh STANDARDS 115The 116.Fn ulimit 117function conforms to 118.St -xsh5 . 119