getrlimit.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 147 行

2
147
字号
.\" SCCSID: @(#)getrlimit.2	2.5	8/10/87.TH getrlimit 2.SH Namegetrlimit, setrlimit \- control maximum system resource consumption.SH Syntax.ft B.nf#include <sys/time.h>#include <sys/resource.h>.PP.ft Bgetrlimit(resource, rlp)int resource;struct rlimit *rlp;.PP.ft Bsetrlimit(resource, rlp)int resource;struct rlimit *rlp;.fi.ft R.SH Description.NXR "getrlimit system call".NXR "setrlimit system call".NXR "process" "controlling resource consumption"Limits on the consumption of system resources by the current processand each process it creates can be obtained with the.PN getrlimitcall and set with the.PN setrlimitcall.  .PPThe.I resourceparameter is one of the following:.NXR "getrlimit system call" "parameter list".TP 17RLIMIT_CPUthe maximum amount of cpu time (in milliseconds) to be used byeach process..TP 17RLIMIT_FSIZEthe largest size, in bytes, of any single file that may be created..TP 17RLIMIT_DATAthe maximum size, in bytes, of the data segment for a process.This limit defines how far a program can extend its break with the.PN sbrk system call..TP 17RLIMIT_STACKthe maximum size, in bytes, of the stack segment for a process.This limit defines how far a program's stack segment can be extended,either automatically by the system or explicitly by a user, withthe .PN sbrk system call..TP 17RLIMIT_COREthe largest size, in bytes, of a .I corefile that may be created..TP 17RLIMIT_RSSthe maximum size, in bytes, to which a process's resident set size maygrow when there is a shortage of free physical memory. Exceeding this limit when free physical memory is in short supplyresults in an unfavorablescheduling priority being assigned to the process..PPA resource limit is specified as a soft limit and a hard limit.When a soft limit is exceeded, a process may receive a signal(for example, if the cpu time is exceeded), but it will be allowedto continue execution until it reaches the hard limit (or modifiesits resource limit).  The system uses just the soft limit field of theresources RLIMIT_CORE and RLIMIT_RSS. The .I rlimitstructure is used to specify the hard and soft limits on a resource, asshown:.NXR "soft limit" "specifying".NXR "hard limit" "specifying".EXstruct rlimit {	int	rlim_cur;	/* current (soft) limit */	int	rlim_max;	/* hard limit */};.EE.PPOnly the superuser may raise the maximum limits.  Other usersmay alter .I rlim_curwithin the range from 0 to .I rlim_maxor (irreversibly) lower.IR rlim_max ..PPAn \*(lqinfinite\*(rq value for a limit is defined as RLIM_INFINITY(0x7\&f\&f\&f\&f\&f\&f\&f)..PPBecause this information is stored in the per-process information,this system call must be executed directly by the shell if itis to affect all future processes created by the shell;.I limitis thus a built-in command to .PN csh ..PPThe system refuses to extend the data or stack space when the limitswould be exceeded in the normal way: a.I breakcall fails if the data space limit is reached, or the process iskilled when the stack limit is reached.  Because the stack cannot beextended, there is no way to send a signal..PPA file I/O operation that creates too large a file causes the SIGXFSZ signal to be generated. This condition normally terminatesthe process, but may be caught.When the soft cpu time limit is exceeded,a signal SIGXCPU is sent to theprocess..SH Return ValuesA 0 return value indicates that the call succeeded, changingor returning the resource limit.   A return value of \-1 indicatesthat an error occurred, and an error code is stored in the globallocation \fIerrno\fP..SH Environment.SS System FiveWhen your program is compiled in the System V environment, the SIGXFSZ signal is notgenerated..SH DiagnosticsThe .PN getrlimitcall fails under the following conditions:.TP 15[EFAULT]The address specified for \fIrlp\fP is invalid..TP 15[EPERM]The limit specified to .PN setrlimitwould have raised the maximum limit value,and the caller is not the superuser..TP 15[EINVAL]Resource is greater than or equal to RLIM_NLIMITS..SH See Alsocsh(1), quota(2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?