{"id":448,"date":"2016-09-01T11:27:15","date_gmt":"2016-09-01T03:27:15","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=448"},"modified":"2016-12-01T15:27:19","modified_gmt":"2016-12-01T07:27:19","slug":"%e8%bf%9b%e7%a8%8b%e7%bb%9f%e8%ae%a1%ef%bc%88process-accounting%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=448","title":{"rendered":"\u8fdb\u7a0b\u7edf\u8ba1\uff08Process Accounting\uff09"},"content":{"rendered":"<p>\u591a\u6570UNIX\u7cfb\u7edf\u63d0\u4f9b\u4e00\u4e2a\u8fdb\u7a0b\u7edf\u8ba1\u7684\u9009\u9879\u3002\u5f53\u5f00\u542f\u65f6\uff0c\u6bcf\u6b21\u6709\u8fdb\u7a0b\u7ec8\u6b62\u65f6\u90fd\u4f1a\u5199\u4e00\u6761\u8bb0\u5f55\u3002\u8fd9\u4e9b\u8bb0\u5f55\u8bb0\u8f7d\u4e86\u547d\u4ee4\u540d\u3001CPU\u4f7f\u7528\u65f6\u95f4\u3001\u7528\u6237ID\u3001\u7ec4ID\u548c\u5f00\u59cb\u65f6\u95f4\u7b49\u7b49\u3002<\/p>\n<p>\u8d85\u7ea7\u7528\u6237\u6267\u884c<span style=\"color: #993300;\">accton<\/span>\u547d\u4ee4\u5e26\u4e00\u4e2a\u8def\u5f84\u53c2\u6570\u53ef\u4ee5\u5f00\u542f\u7edf\u8ba1\u8bb0\u5f55\u529f\u80fd\uff0c\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u5173\u95ed\u7edf\u8ba1\u529f\u80fd\u3002<\/p>\n<p>\u4e0d\u540c\u5e73\u53f0\u7684\u8def\u5f84\u901a\u5e38\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>FreeBSD\u548cMac OS X\uff1a\/var\/account\/acct<\/li>\n<li>Linux\uff1a\/var\/account\/pacct<\/li>\n<li>Solaris\uff1a\/var\/adm\/pacct<\/li>\n<\/ul>\n<p>\u7edf\u8ba1\u8bb0\u5f55\uff08accounting record\uff09\u662f\u5bf9\u5e94\u4e8e\u8fdb\u7a0b\u7684\uff0c\u800c\u4e0d\u662f\u7a0b\u5e8f\u3002\u7531\u5185\u6838\u5728<span style=\"color: #993300;\">fork<\/span>\u4e4b\u540e\u4e3a\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u8bb0\u5f55\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u65b0\u7a0b\u5e8f\u88ab\u6267\u884c\u3002\u867d\u7136<span style=\"color: #993300;\">exec<\/span>\u4e0d\u80fd\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7edf\u8ba1\u8bb0\u5f55\uff0c\u4f46\u662f\u547d\u4ee4\u540d\u4f1a\u6539\u53d8\uff0c\u5e76\u4e14<span style=\"color: #993300;\">AFORK<\/span>\u6807\u8bb0\u88ab\u6e05\u9664\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5982\u679c\u6211\u4eec\u6709\u4e00\u4e2a\u7531\u4e09\u4e2a\u7a0b\u5e8f\u7ec4\u6210\u7684\u94fe\u2014\u2014A exec B, B exec C\uff0c \u6700\u540eC\u9000\u51fa\uff0c\u8fd9\u65f6\u53ea\u5199\u4e00\u6761\u7edf\u8ba1\u8bb0\u5f55\u3002\u547d\u4ee4\u540d\u6700\u540e\u5199\u7684\u662fC\uff0c\u4f46\u662fCPU\u65f6\u95f4\u662f\u4e09\u4e2a\u7a0b\u5e8f\u7684\u603b\u548c\u3002<\/p>\n<p>\u7edf\u8ba1\u8bb0\u5f55\u5b9a\u4e49\u5728<span style=\"color: #993300;\">&lt;sys\/acct.h&gt;<\/span>\u5934\u6587\u4ef6\u4e2d\uff0c\u770b\u4e0a\u53bb\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<table style=\"height: 849px;\" border=\"0\" width=\"527\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<pre><span style=\"color: #993300;\">typedef  u_short comp_t;   \/* 3-bit base 8 exponent; 13-bit fraction *\/\r\n\r\nstruct  acct\r\n{\r\n  char   ac_flag;     \/* flag (see <a class=\"docLink\" style=\"color: #993300;\" href=\"#ch08fig26\">Figure 8.26<\/a>) *\/\r\n  char   ac_stat;     \/* termination status (signal &amp; core flag only) *\/\r\n                      \/* (Solaris only) *\/\r\n  uid_t  ac_uid;      \/* real user ID *\/\r\n  gid_t  ac_gid;      \/* real group ID *\/\r\n  dev_t  ac_tty;      \/* controlling terminal *\/\r\n  time_t ac_btime;    \/* starting calendar time *\/\r\n  comp_t ac_utime;    \/* user CPU time (clock ticks) *\/\r\n  comp_t ac_stime;    \/* system CPU time (clock ticks) *\/\r\n  comp_t ac_etime;    \/* elapsed time (clock ticks) *\/\r\n  comp_t ac_mem;      \/* average memory usage *\/\r\n  comp_t ac_io;       \/* bytes transferred (by read and write) *\/\r\n                      \/* \"blocks\" on BSD systems *\/\r\n  comp_t ac_rw;       \/* blocks read or written *\/\r\n                      \/* (not present on BSD systems) *\/\r\n  char   ac_comm[8];  \/* command name: [8] for Solaris, *\/\r\n                      \/* [10] for Mac OS X, [16] for FreeBSD, and *\/\r\n                      \/* [17] for Linux *\/\r\n};\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #993300;\">ac_stat<\/span>\u6210\u5458\u5e76\u4e0d\u662f\u8fdb\u7a0b\u771f\u6b63\u7ec8\u6b62\u7684\u72b6\u6001\uff0c\u4f46\u662f\u5b83\u662f\u7ec8\u6b62\u72b6\u6001\u7684\u4e00\u90e8\u5206\u3002\u5982\u679c\u8fdb\u7a0b\u4e0d\u662f\u6b63\u5e38\u7ec8\u6b62\u7684\uff0c\u8fd9\u4e2a\u5b57\u8282\u4e2d\u552f\u4e00\u7684\u4fe1\u606f\u662fcore-flag\u4f4d\uff08\u901a\u5e38\u662f\u9ad8\u4f4d\uff09\u548c\u4fe1\u53f7\u6570\uff08\u901a\u5e38\u662f\u4f4e\u4e03\u4f4d\uff09\u3002\u5982\u679c\u8fdb\u7a0b\u662f\u6b63\u5e38\u7ed3\u675f\uff0c\u662f\u4e0d\u80fd\u4ece\u7edf\u8ba1\u6587\u4ef6\u4e2d\u5f97\u5230<span style=\"color: #993300;\">exit<\/span>\u72b6\u6001\u7684\u3002<\/p>\n<p><span style=\"color: #993300;\">ac_flag<\/span>\u3002<span style=\"color: #993300;\">F<\/span>\u6807\u8bb0\u662f\u7ed9\u6240\u6709\u5b50\u8fdb\u7a0b\u8bbe\u7f6e\u7684\uff08\u9664\u975e\u5b50\u8fdb\u7a0b\u6267\u884c\u4e86<span style=\"color: #993300;\">exec<\/span>\uff09\u3002<\/p>\n<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<table class=\"allBorders\" style=\"height: 579px;\" border=\"1\" width=\"501\" rules=\"groups\" cellspacing=\"0\" cellpadding=\"5\">\n<caption>\n<h5 class=\"docTableTitle\">Figure 8.26. Values for <tt>ac_flag<\/tt> from accounting record<\/h5>\n<\/caption>\n<colgroup>\n<col width=\"75\" \/>\n<col width=\"200\" \/>\n<col width=\"57\" \/>\n<col width=\"56\" \/>\n<col width=\"56\" \/>\n<col width=\"56\" \/><\/colgroup>\n<thead>\n<tr>\n<th class=\"rightBorder bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"middle\">\n<p class=\"docText\"><span class=\"docEmphRoman\"><tt>ac_flag<\/tt><\/span><\/p>\n<\/th>\n<th class=\"rightBorder bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"middle\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Description<\/span><\/p>\n<\/th>\n<th class=\"bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"bottom\">\n<p class=\"docText\"><span class=\"docEmphRoman\">FreeBSD 5.2.1<\/span><\/p>\n<\/th>\n<th class=\"bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"bottom\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Linux 2.4.22<\/span><\/p>\n<\/th>\n<th class=\"bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"bottom\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Mac OS X 10.3<\/span><\/p>\n<\/th>\n<th class=\"bottomBorder thead\" scope=\"col\" align=\"center\" valign=\"bottom\">\n<p class=\"docText\"><span class=\"docEmphRoman\">Solaris 9<\/span><\/p>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>AFORK<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>\u8fdb\u7a0b\u662f\u7531fork\u4ea7\u751f\u7684\uff0c\u4f46\u4ece\u672a\u8c03\u7528exec<\/tt><\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>ASU<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u8fdb\u7a0b\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u6743\u9650<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>ACOMPAT<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u8fdb\u7a0b\u4f7f\u7528\u517c\u5bb9\u6a21\u5f0f<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<\/tr>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>ACORE<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\">process dumped core<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<\/tr>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>AXSIG<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\">\u8fdb\u7a0b\u7531\u4fe1\u53f7\u7ec8\u6b62<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<\/tr>\n<tr>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\"><tt>AEXPND<\/tt><\/p>\n<\/td>\n<td class=\"rightBorder\" align=\"left\" valign=\"top\">\n<p class=\"docText\">expanded accounting entry<\/p>\n<\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\"><\/td>\n<td class=\"docTableCell\" align=\"center\" valign=\"top\">\n<p class=\"docText\">\u2022<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u591a\u6570UNIX\u7cfb\u7edf\u63d0\u4f9b\u4e00\u4e2a\u8fdb\u7a0b\u7edf\u8ba1\u7684\u9009\u9879\u3002\u5f53\u5f00\u542f\u65f6\uff0c\u6bcf\u6b21\u6709\u8fdb\u7a0b\u7ec8\u6b62\u65f6\u90fd\u4f1a\u5199\u4e00\u6761\u8bb0\u5f55\u3002\u8fd9\u4e9b\u8bb0\u5f55\u8bb0\u8f7d\u4e86\u547d\u4ee4\u540d\u3001CPU\u4f7f\u7528\u65f6\u95f4\u3001\u7528\u6237ID\u3001\u7ec4ID\u548c\u5f00\u59cb\u65f6\u95f4\u7b49\u7b49\u3002 \u8d85\u7ea7\u7528&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=448\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-448","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/448","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=448"}],"version-history":[{"count":6,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions"}],"predecessor-version":[{"id":460,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions\/460"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}