Annotation of 43BSDReno/lib/libc/sys/getrlimit.2, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1980 The Regents of the University of California.
                      2: .\" All rights reserved.
                      3: .\"
                      4: .\" Redistribution and use in source and binary forms are permitted provided
                      5: .\" that: (1) source distributions retain this entire copyright notice and
                      6: .\" comment, and (2) distributions including binaries display the following
                      7: .\" acknowledgement:  ``This product includes software developed by the
                      8: .\" University of California, Berkeley and its contributors'' in the
                      9: .\" documentation or other materials provided with the distribution and in
                     10: .\" all advertising materials mentioning features or use of this software.
                     11: .\" Neither the name of the University nor the names of its contributors may
                     12: .\" be used to endorse or promote products derived from this software without
                     13: .\" specific prior written permission.
                     14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     17: .\"
                     18: .\"    @(#)getrlimit.2 6.6 (Berkeley) 6/23/90
                     19: .\"
                     20: .TH GETRLIMIT 2 "June 23, 1990"
                     21: .UC 4
                     22: .SH NAME
                     23: getrlimit, setrlimit \- control maximum system resource consumption
                     24: .SH SYNOPSIS
                     25: .ft B
                     26: .nf
                     27: #include <sys/time.h>
                     28: #include <sys/resource.h>
                     29: .PP
                     30: .ft B
                     31: getrlimit(resource, rlp)
                     32: int resource;
                     33: struct rlimit *rlp;
                     34: .PP
                     35: .ft B
                     36: setrlimit(resource, rlp)
                     37: int resource;
                     38: struct rlimit *rlp;
                     39: .fi
                     40: .ft R
                     41: .SH DESCRIPTION
                     42: Limits on the consumption of system resources by the current process
                     43: and each process it creates may be obtained with the
                     44: .I getrlimit
                     45: call, and set with the
                     46: .I setrlimit
                     47: call.  
                     48: .PP
                     49: The
                     50: .I resource
                     51: parameter is one of the following:
                     52: .TP 17
                     53: RLIMIT_CPU
                     54: the maximum amount of cpu time (in seconds) to be used by
                     55: each process.
                     56: .TP 17
                     57: RLIMIT_FSIZE
                     58: the largest size, in bytes, of any single file that may be created.
                     59: .TP 17
                     60: RLIMIT_DATA
                     61: the maximum size, in bytes, of the data segment for a process;
                     62: this defines how far a program may extend its break with the
                     63: .IR sbrk (2)
                     64: system call.
                     65: .TP 17
                     66: RLIMIT_STACK
                     67: the maximum size, in bytes, of the stack segment for a process;
                     68: this defines how far a program's stack segment may be extended.
                     69: Stack extension is performed automatically by the system.
                     70: .TP 17
                     71: RLIMIT_CORE
                     72: the largest size, in bytes, of a 
                     73: .I core
                     74: file that may be created.
                     75: .TP 17
                     76: RLIMIT_RSS
                     77: the maximum size, in bytes, to which a process's resident set size may
                     78: grow.  This imposes a limit on the amount of physical memory
                     79: to be given to a process; if memory is tight, the system will
                     80: prefer to take memory from processes that are exceeding their
                     81: declared resident set size.
                     82: .PP
                     83: A resource limit is specified as a soft limit and a hard limit.  When a
                     84: soft limit is exceeded a process may receive a signal (for example, if
                     85: the cpu time or file size is exceeded), but it will be allowed to
                     86: continue execution until it reaches the hard limit (or modifies
                     87: its resource limit).  The 
                     88: .I rlimit
                     89: structure is used to specify the hard and soft limits on a resource,
                     90: .PP
                     91: .nf
                     92: .RS
                     93: .DT
                     94: struct rlimit {
                     95:        int     rlim_cur;       /* current (soft) limit */
                     96:        int     rlim_max;       /* hard limit */
                     97: };
                     98: .RE
                     99: .fi
                    100: .PP
                    101: Only the super-user may raise the maximum limits.  Other users
                    102: may only alter 
                    103: .I rlim_cur
                    104: within the range from 0 to 
                    105: .I rlim_max
                    106: or (irreversibly) lower
                    107: .IR rlim_max .
                    108: .PP
                    109: An \*(lqinfinite\*(rq value for a limit is defined as RLIM_INFINITY
                    110: (0x7\&f\&f\&f\&f\&f\&f\&f).
                    111: .PP
                    112: Because this information is stored in the per-process information,
                    113: this system call must be executed directly by the shell if it
                    114: is to affect all future processes created by the shell;
                    115: .I limit
                    116: is thus a built-in command to
                    117: .IR csh (1).
                    118: .PP
                    119: The system refuses to extend the data or stack space when the limits
                    120: would be exceeded in the normal way: a
                    121: .I break
                    122: call fails if the data space limit is reached.
                    123: When the stack limit is reached, the process receives
                    124: a segmentation fault (SIGSEGV); if this signal is not
                    125: caught by a handler using the signal stack, this signal
                    126: will kill the process.
                    127: .PP
                    128: A file I/O operation that would create a file larger that the process'
                    129: soft limit will cause the write to fail and a signal SIGXFSZ to be
                    130: generated; this normally terminates the process, but may be caught.  When
                    131: the soft cpu time limit is exceeded, a signal SIGXCPU is sent to the
                    132: offending process.
                    133: .SH "RETURN VALUE
                    134: A 0 return value indicates that the call succeeded, changing
                    135: or returning the resource limit.   A return value of \-1 indicates
                    136: that an error occurred, and an error code is stored in the global
                    137: location \fIerrno\fP.
                    138: .SH "ERRORS
                    139: The possible errors are:
                    140: .TP 15
                    141: [EFAULT]
                    142: The address specified for \fIrlp\fP is invalid.
                    143: .TP 15
                    144: [EPERM]        The limit specified to \fIsetrlimit\fP would have
                    145: raised the maximum limit value, and the caller is not the super-user.
                    146: .SH SEE ALSO
                    147: csh(1), quota(2), sigvec(2), sigstack(2)
                    148: .SH BUGS
                    149: There should be 
                    150: .I limit
                    151: and
                    152: .I unlimit
                    153: commands in
                    154: .IR sh (1)
                    155: as well as in
                    156: .IR csh.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.