{"id":350,"date":"2016-08-08T14:52:37","date_gmt":"2016-08-08T06:52:37","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=350"},"modified":"2016-08-08T15:26:39","modified_gmt":"2016-08-08T07:26:39","slug":"getrlimit%e5%92%8csetrlimit%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=350","title":{"rendered":"getrlimit\u548csetrlimit\u51fd\u6570"},"content":{"rendered":"<p>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u4e00\u7ec4\u8d44\u6e90\u9650\u5236\uff0c\u5b83\u4eec\u4e2d\u7684\u4e00\u4e9b\u53ef\u4ee5\u88ab<span style=\"color: #993300;\">getrlimit<\/span>\u548c<span style=\"color: #993300;\">setrlimit<\/span>\u51fd\u6570\u67e5\u8be2\u548c\u6539\u53d8\u3002<\/p>\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<table class=\"allBorders\" border=\"1\" rules=\"none\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<pre>  #include &lt;sys\/resource.h&gt;\r\n\r\n  int getrlimit(int <span class=\"docEmphItalicAlt\">resource<\/span>, struct rlimit *<span class=\"docEmphItalicAlt\">rlptr<\/span>);\r\n\r\n  int setrlimit(int <span class=\"docEmphItalicAlt\">resource<\/span>, const struct rlimit \r\n*<span class=\"docEmphItalicAlt\">rlptr<\/span>);\r\n<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"right\" valign=\"top\">\n<p class=\"docText\">Both return: 0 if OK, nonzero on error<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e2dsingle UNIX Specification\u4e2d\u505a\u4e3aXSI\u6269\u5c55\u88ab\u5b9a\u4e49\u3002\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\u662f\u5728\u7cfb\u7edf\u521d\u59cb\u5316\u65f6\u7531\u8fdb\u7a0b0\u5efa\u7acb\u7684\uff0c\u7136\u540e\u7531\u6bcf\u4e2a\u540e\u7eed\u8fdb\u7a0b\u7ee7\u627f\u3002\u6bcf\u79cd\u5b9e\u73b0\u90fd\u53ef\u4ee5\u7528\u81ea\u5df1\u7684\u65b9\u6cd5\u5bf9\u5404\u79cd\u9650\u5236\u505a\u51fa\u8c03\u6574\u3002<\/p>\n<p>\u6bcf\u5f53\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u65f6\uff0c\u90fd\u4f1a\u6307\u5b9a\u4e00\u4e2a\u8d44\u6e90\u548c\u4e00\u4e2a\u6307\u5411\u5982\u4e0b\u7ed3\u6784\u7684\u6307\u9488\uff1a<\/p>\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<pre><span style=\"color: #993300;\">   struct rlimit {\r\n      rlim_t  rlim_cur;   \/* soft limit: current limit *\/\r\n      rlim_t  rlim_max;   \/* hard limit: maximum value for rlim_cur *\/\r\n    };\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e09\u4e2a\u6539\u53d8\u8d44\u6e90\u9650\u5236\u7684\u89c4\u5219\uff1a<\/p>\n<ol>\n<li>\u4e00\u4e2a\u8fdb\u7a0b\u80fd\u6539\u53d8\u5b83\u7684\u8f6f\u9650\u5236\u503c\u5c0f\u4e8e\u7b49\u4e8e\u5b83\u7684\u786c\u9650\u5236\u503c\u3002<\/li>\n<li>\u4e00\u4e2a\u8fdb\u7a0b\u80fd\u964d\u4f4e\u5b83\u7684\u786c\u9650\u5236\u503c\u5927\u4e8e\u7b49\u4e8e\u5b83\u7684\u8f6f\u9650\u5236\u503c\u3002\u5bf9\u4e8e\u666e\u901a\u7528\u6237\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u4e0d\u53ef\u9006\u8f6c\u7684\u3002<\/li>\n<li>\u53ea\u6709\u8d85\u7ea7\u7528\u6237\u6709\u80fd\u529b\u63d0\u5347\u786c\u9650\u5236\u503c\u3002<\/li>\n<\/ol>\n<p>\u5e38\u91cf<span style=\"color: #993300;\">RLIM_INFINITY<\/span>\u6307\u5b9a\u4e86\u65e0\u9650\u91cf\u7684\u9650\u5236\u3002<\/p>\n<p><em>resource<\/em>\u53c2\u6570\u503c\u53ef\u4ee5\u8be6\u89c17.11\u7684 FIGURE 7.15<\/p>\n<p>\u8d44\u6e90\u9650\u5236\u53ef\u4ee5\u5f71\u54cd\u8c03\u7528\u7684\u8fdb\u7a0b\u548c\u4ece\u5b83\u90a3\u91cc\u7ee7\u627f\u7684\u5b50\u8fdb\u7a0b\u3002\u8fd9\u610f\u5473\u7740\u8d44\u6e90\u9650\u5236\u7684\u8bbe\u7f6e\u9700\u8981\u5185\u5d4c\u5230shell\u91cc\uff0c\u7528\u4e8e\u4f5c\u7528\u5230\u6211\u4eec\u6240\u6709\u7684\u8fdb\u7a0b\u3002Bourne shell\u3001GNU Bourne-again shell\u548cKorn shell\u5185\u5efa\u4e86<span style=\"color: #993300;\">ulimit<\/span>\u547d\u4ee4\uff0cC shell\u5185\u5efa\u4e86<span style=\"color: #993300;\">limit<\/span>\u547d\u4ee4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u4e00\u7ec4\u8d44\u6e90\u9650\u5236\uff0c\u5b83\u4eec\u4e2d\u7684\u4e00\u4e9b\u53ef\u4ee5\u88abgetrlimit\u548csetrlimit\u51fd\u6570\u67e5\u8be2\u548c\u6539\u53d8\u3002 #include &lt;sys\/resource.h&#038;gt&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=350\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-350","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350"}],"version-history":[{"count":6,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"predecessor-version":[{"id":356,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions\/356"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}