getrlimit , setrlimit 函数

 
NAME
getrlimit, setrlimit - control maximum resource consumption
SYNOPSIS
[XSI] [Option Start] #include <sys/resource.h>

int getrlimit(int
resource, struct rlimit *rlp);
int setrlimit(int
resource, const struct rlimit *rlp); [Option End]


描述

The getrlimit () function shall get, and the setrlimit () function shall set, limits on the consumption of a variety of resources.getrlimit ( )的功能将得到和setrlimit ( )函数会设定限额,对消费的各种资源.

Each call to either getrlimit () or setrlimit () identifies a specific resource to be operated upon as well as a resource limit.每次通话要么getrlimit ( )或setrlimit ( )确定了具体的资源必须经手术治疗,以及资源的限制. A resource limit is represented by an rlimit structure.资源限制是代表一个rlimit结构. The rlim_cur member specifies the current or soft limit and the rlim_max member specifies the maximum or hard limit.rlim_cur会员说明当前或软限制,以及会员rlim_max明最高或硬极限. Soft limits may be changed by a process to any value that is less than or equal to the hard limit.软限制,可改变一个进程的任何值小于或等于硬限制. A process may (irreversibly) lower its hard limit to any value that is greater than or equal to the soft limit.一个进程可以(不可逆)降低其硬限制的任何值是大于或等于软限制. Only a process with appropriate privileges can raise a hard limit.只是一个过程,适当的特权,可以提高硬限制. Both hard and soft limits can be changed in a single call to setrlimit () subject to the constraints described above.软硬限制,可以改变单一调用setrlimit ( )除上文所述的制约.

The value RLIM_INFINITY, defined in <sys/resource.h> , shall be considered to be larger than any other limit value.价值rlim_infinity界定<sys/resource.h>时,应考虑将大于其他任何限定值. If a call to getrlimit () returns RLIM_INFINITY for a resource, it means the implementation shall not enforce limits on that resource.如果调用getrlimit ( )返回rlim_infinity为一种资源,它意味着必须执行,不得强制执行的限制对这一资源. Specifying RLIM_INFINITY as any resource limit value on a successful call to setrlimit () shall inhibit enforcement of that resource limit.明rlim_infinity任何资源限值就成功调用setrlimit ( )不得妨碍执法资源限制.

The following resources are defined:下列资源是指:

RLIMIT_CORE rlimit_core
This is the maximum size of a core file, in bytes, that may be created by a process.这是规模最大的一个核心文件,以字节,也可以被创造的一个过程. A limit of 0 shall prevent the creation of a core file.限额0不得妨碍建立一个核心文件. If this limit is exceeded, the writing of a core file shall terminate at this size.如果这个限额,超出写作的一个核心文件应终止在这个规模.
RLIMIT_CPU rlimit_cpu
This is the maximum amount of CPU time, in seconds, used by a process.这是最高限额cpu时间,以秒表示,用一个过程. If this limit is exceeded, SIGXCPU shall be generated for the process.如果这个限额,超出sigxcpu应产生过程. If the process is catching or ignoring SIGXCPU, or all threads belonging to that process are blocking SIGXCPU, the behavior is unspecified.如果该进程捕捉或无视sigxcpu ,或所有线程属于这一进程受阻sigxcpu ,行为是不详.
RLIMIT_DATA rlimit_data
This is the maximum size of a process' data segment, in bytes.这是规模最大的一个进程的数据部分,在字节. If this limit is exceeded, the malloc () function shall fail with errno set to [ENOMEM]. 如果这个限额,超出政府的malloc ( )函数将失败, errno设置[ enomem ] .
RLIMIT_FSIZE rlimit_fsize
This is the maximum size of a file, in bytes, that may be created by a process.这是规模最大的一个文件,字节,也可以被创造的一个过程. If a write or truncate operation would cause this limit to be exceeded, SIGXFSZ shall be generated for the thread.如果写信或截断的行动会导致这样的限制将超过sigxfsz应产生螺纹. If the thread is blocking, or the process is catching or ignoring SIGXFSZ, continued attempts to increase the size of a file from end-of-file to beyond the limit shall fail with errno set to [EFBIG].如果线程阻塞,或过程,是捕捉或无视sigxfsz ,企图继续扩大市场规模,一个文件,从文件末尾超越极限应不成errno设置[ efbig ] .
RLIMIT_NOFILE rlimit_nofile
This is a number one greater than the maximum value that the system may assign to a newly-created descriptor.这是一个数目大于最高值,该系统可指派一个新设的描述. If this limit is exceeded, functions that allocate a file descriptor shall fail with errno set to [EMFILE].如果这个限额,超出职能分配一个文件描述应不成errno设置[ emfile ] . This limit constrains the number of file descriptors that a process may allocate.这个限额限制人数文件描述符的一个过程,可分配.
RLIMIT_STACK rlimit_stack
This is the maximum size of the initial thread's stack, in bytes.这是规模最大的初始线程的堆栈,在字节. The implementation does not automatically grow the stack beyond this limit.执行不会自动增长堆栈超出这一限度. If this limit is exceeded, SIGSEGV shall be generated for the thread.如果这个限额,超出sigsegv应产生螺纹. If the thread is blocking SIGSEGV, or the process is ignoring or catching SIGSEGV and has not made arrangements to use an alternate stack, the disposition of SIGSEGV shall be set to SIG_DFL before it is generated.如果线程阻塞sigsegv或过程是无视或捉sigsegv并未作出安排,以候补栈,处置sigsegv应设定sig_dfl之前,它的产生.
RLIMIT_AS rlimit_as
This is the maximum size of a process' total available memory, in bytes.这是规模最大的一个进程的总的内存,在字节. If this limit is exceeded, the malloc () and mmap () functions shall fail with errno set to [ENOMEM]. 如果超过规定限额, malloc ( )mmap ( )函数将失败, errno设置[ enomem ] . In addition, the automatic stack growth fails with the effects outlined above.此外,自动堆栈增长未能与效果刚好相反.

When using the getrlimit () function, if a resource limit can be represented correctly in an object of type rlim_t , then its representation is returned; otherwise, if the value of the resource limit is equal to that of the corresponding saved hard limit, the value returned shall be RLIM_SAVED_MAX; otherwise, the value returned shall be RLIM_SAVED_CUR.当使用getrlimit ( )的功能,如果一种资源限制,可较正确的对象类型rlim_t ,那么其代表性是归还;否则,如果该值的资源限制是相等,即相应节省硬限制,返回值应rlim_saved_max ;否则,返回值应rlim_saved_cur .

When using the setrlimit () function, if the requested new limit is RLIM_INFINITY, the new limit shall be "no limit''; otherwise, if the requested new limit is RLIM_SAVED_MAX, the new limit shall be the corresponding saved hard limit; otherwise, if the requested new limit is RLIM_SAVED_CUR, the new limit shall be the corresponding saved soft limit; otherwise, the new limit shall be the requested value. In addition, if the corresponding saved limit can be represented correctly in an object of type rlim_t then it shall be overwritten with the new limit.当使用setrlimit ( )函数,如果要求新的限制是rlim_infinity ,新的上限应为"没有限制'' ;否则,如果要求新的限制是rlim_saved_max ,新的限制,应相应节省硬极限;否则,如果要求新的限制是rlim_saved_cur ,新的限额应相应节省软极限;否则,新的限额应要求值.此外,如果相应节省上限可代表正确的对象类型rlim_t那么它应被覆盖在新的限额.

The result of setting a limit to RLIM_SAVED_MAX or RLIM_SAVED_CUR is unspecified unless a previous call to getrlimit () returned that value as the soft or hard limit for the corresponding resource limit.结果设定一个限度或rlim_saved_max rlim_saved_cur是未除非先前调用getrlimit ( ) ,返回值为软或硬限额为相应的资源限制.

The determination of whether a limit can be correctly represented in an object of type rlim_t is implementation-defined.确定是否限制可正确代表一个对象类rlim_t是落实界定. For example, some implementations permit a limit whose value is greater than RLIM_INFINITY and others do not.举例来说,有些实施许可证限制,其价值大于rlim_infinity和别人不.

The exec family of functions shall cause resource limits to be saved. 掌门家庭职能造成了资源限制,可以节省很多.

RETURN VALUE返回值

Upon successful completion, getrlimit () and setrlimit () shall return 0.如果顺利完成, getrlimit ( )和setrlimit ( )将返回0 . Otherwise, these functions shall return -1 and set errno to indicate the error.否则,这些功能将返回-1 , errno设定显示错误.

ERRORS误差

The getrlimit () and setrlimit () functions shall fail if:getrlimit ( )和setrlimit ( )函数将失败:

[EINVAL] [ einval ]
An invalid resource was specified; or in a setrlimit () call, the new rlim_cur exceeds the new rlim_max .无效的资源被指定;或在setrlimit ( )调用,新rlim_cur超过新rlim_max .
[EPERM] [ eperm ]
The limit specified to setrlimit () would have raised the maximum limit value, and the calling process does not have appropriate privileges.极限指定setrlimit ( ) ,将所提出的最高限值,并调用过程没有适当的特权.

The setrlimit () function may fail if:setrlimit ( )函数可能失败,如果:

[EINVAL] [ einval ]
The limit specified cannot be lowered because current usage is already higher than the limit.极限指明不能降低,因为目前所使用的是已经高于限额.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值