I. Resource limitations of processes and signals

Source: Internet
Author: User

Process resource Functions

#include <sys/resource.h>Get user ResourcesintGetrlimit (intResourcestructRlimit *rlptr); Set User ResourcesintSetrlimit (intResourcestructRlimit *rlptr); kernel resource structurestructrlimit{rlimit_t rlim_cur;/*Soft limit:current limit**/software Resources rlimit_t Rlim_max;/*Hard limit;maximum value for rlim_cur**/Hardware Resources}
Resource value rlimit_as       process available Store size Rlimit_core   CORE file Maximum bytes rlimit_cpu     CPU time Max Rlimit_data   Maximum length of data segment rlimit_fsize the maximum  number of rlimit_locks file locks rlimit_memlock use Mlock to lock the longest number of bytes in memory rlimit_nofile   The maximum number of files that can be opened rlimit_nproc the maximum number of processes per user ID Rlimit_rss The maximum length of Rlimit_stack stack for the maximum     stored set byte length

Get System Resource parameters

#include <sys/resource.h>#include<stdlib.h>#include<stdio.h>#include<string.h>#defineRlimit (name) get_limit (#name, name)voidGet_limit (Char*name,intResource) {    structRlimit limit; if(Getrlimit (Resource,&limit) <0) {printf ("Get limit Resource error"); return ; } printf ("%-15s", name); if(limit.rlim_cur==rlim_infinity) {printf ("Infinity"); }    Else{printf ("%10ld", Limit.rlim_cur); }    if(limit.rlim_max==rlim_infinity) {printf ("infinity\n"); }    Else{printf ("%10ld\n", Limit.rlim_max); }    return;}intMain () {rlimit (rlimit_as);    Rlimit (Rlimit_core);    Rlimit (RLIMIT_CPU);    Rlimit (Rlimit_data);    Rlimit (rlimit_fsize);    Rlimit (rlimit_locks);    Rlimit (Rlimit_memlock);    Rlimit (Rlimit_nofile);    Rlimit (RLIMIT_NPROC);    Rlimit (RLIMIT_RSS);    Rlimit (Rlimit_stack); return 0;}

Results

rlimit_as       Infinity infinityrlimit_core             0  infinityrlimit_cpu      Infinity Infinityrlimit_data     Infinity infinityrlimit_fsize    Infinity infinityrlimit_locks    Infinity Infinityrlimit_memlock      65536     65536rlimit_nofile        1024      65536rlimit_nproc         3749      3749Rlimit_rss      Infinity Infinityrlimit_stack       8388608 Infinity

Linux System Resource Throttling configuration

/etc/security/limits.conf File open limit system already exists, 0, File Open,1, file output,2, file error

I. Resource limitations of processes and signals

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.