{"id":744,"date":"2017-03-09T14:35:34","date_gmt":"2017-03-09T06:35:34","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=744"},"modified":"2017-03-13T15:02:00","modified_gmt":"2017-03-13T07:02:00","slug":"%e9%99%84%e5%8a%a0%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=744","title":{"rendered":"\u9644\u52a0\u529f\u80fd"},"content":{"rendered":"<p>\u5728\u8fd9\u8282\uff0c\u6211\u4eec\u63cf\u8ff0\u4e00\u4e9b\u4f9d\u8d56\u4e8e\u5177\u4f53\u5b9e\u73b0\u7684\u9644\u52a0\u4fe1\u53f7\u529f\u80fd\u3002<\/p>\n<h2>\u4fe1\u53f7\u540d<\/h2>\n<p>\u4e00\u4e9b\u7cfb\u7edf\u63d0\u4f9b\u4e86\u6570\u7ec4<\/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;\">   extern char *sys_siglist[];\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6570\u7ec4\u7684\u7d22\u5f15\u662f\u4fe1\u53f7\u53f7\uff0c\u901a\u8fc7\u6307\u9488\u6307\u5411\u4fe1\u53f7\u540d\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u3010FreeBSD 5.2.1, Linux 2.4.22\u548cMac OS X 10.3\u90fd\u63d0\u4f9b\u8fd9\u4e2a\u4fe1\u53f7\u540d\u6570\u7ec4\u3002Solaris 9\u4e5f\u8fd9\u4e48\u505a\uff0c\u4e0d\u8fc7\u5b83\u4f7f\u7528\u7684\u540d\u5b57\u662f<span style=\"color: #993300;\">_sys_siglist<\/span>\u3002\u3011<\/p>\n<p>\u8fd9\u4e9b\u7cfb\u7edf\u4e00\u822c\u4e5f\u63d0\u4f9b<span style=\"color: #993300;\">psignal<\/span>\u51fd\u6570\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: 96px;\" border=\"1\" width=\"429\" rules=\"none\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<pre><span style=\"color: #993300;\">#include &lt;signal.h&gt;\r\n\r\nvoid psignal(int <span class=\"docEmphItalicAlt\">signo<\/span>, const char *<span class=\"docEmphItalicAlt\">msg<\/span>);\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b57\u7b26\u4e32<em>msg<\/em>\uff08\u8fd9\u4e00\u822c\u662f\u7a0b\u5e8f\u540d\uff09\u8f93\u51fa\u5230\u6807\u51c6\u9519\u8bef\uff0c\u540e\u9762\u8ddf\u4e00\u4e2a\u5192\u53f7\u548c\u4e00\u4e2a\u7a7a\u683c\uff0c\u7136\u540e\u662f\u4fe1\u53f7\u7684\u63cf\u8ff0\uff0c\u7136\u540e\u662f\u4e00\u4e2a\u6362\u884c\u7b26\u3002\u8fd9\u4e2a\u51fd\u6570\u7c7b\u4f3c\u4e8e<span style=\"color: #993300;\">perror<\/span>\uff08APUE 1.7\u8282\uff09<\/p>\n<p>\u53e6\u4e00\u4e2a\u5e38\u7528\u51fd\u6570\u662f<span style=\"color: #993300;\">strsignal<\/span>\u3002\u8fd9\u4e2a\u51fd\u6570\u7c7b\u4f3c\u4e8e<span style=\"color: #993300;\">strerror<\/span>\uff08APUE1.7\u8282\uff09<\/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: 179px;\" border=\"1\" width=\"461\" rules=\"none\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<pre><span style=\"color: #993300;\">#include &lt;string.h&gt;\r\n\r\nchar *strsignal(int <span class=\"docEmphItalicAlt\">signo<\/span>);\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"right\" valign=\"top\">\n<p class=\"docText\">Returns: a pointer to a string describing the signal<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ed9\u51fa\u4e00\u4e2a\u4fe1\u53f7\u53f7\uff0cstrsignal\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u5b83\u63cf\u8ff0\u4e86\u8be5\u4fe1\u53f7\u3002\u8fd9\u4e2a\u5b57\u7b26\u4e32\u80fd\u88ab\u5e94\u7528\u7a0b\u5e8f\u6253\u5370\u51fa\u6765\u3002<\/p>\n<p>\u3010APUE\u4e2d\u6240\u63cf\u8ff0\u7684\u6240\u6709\u5e73\u53f0\u90fd\u63d0\u4f9b<span style=\"color: #993300;\">psignal<\/span>\u548c<span style=\"color: #993300;\">strsignal<\/span>\u51fd\u6570\uff0c\u4f46\u4e5f\u6709\u4e00\u4e9b\u4e0d\u540c\u3002\u5728Solaris 9\u4e0a\uff0cstrsignal\u5982\u679c\u4fe1\u53f7\u53f7\u65e0\u6548\uff0c\u90a3\u4e48\u4f1a\u8fd4\u56de\u4e00\u4e2a\u7a7a\u6307\u9488\uff0c\u800cFreeBSD5.2.1, Linux 2.4.22\u548cMac OS X 10.3\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u6307\u660e\u8be5\u4fe1\u53f7\u6ca1\u6709\u6ce8\u518c\u3002\u540c\u6837\uff0c\u5728Solaris\u4e0a\u83b7\u5f97<span style=\"color: #993300;\">psignal<\/span>\u7684\u539f\u5f62\u8981\u5305\u542b<span style=\"color: #993300;\">&lt;siginfo.h&gt;<\/span>\u5934\u6587\u4ef6\u3002<\/p>\n<h2>\u4fe1\u53f7\u6620\u5c04<\/h2>\n<p>Solaris\u63d0\u4f9b\u4e86\u4e00\u5bf9\u51fd\u6570\u5bf9\u5e94\u5c04\u4fe1\u53f7\u53f7\u5230\u4fe1\u53f7\u540d\uff0c\u53cd\u4e4b\u4ea6\u7136\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: 230px;\" border=\"1\" width=\"429\" rules=\"none\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td class=\"docTableCell\" align=\"left\" valign=\"top\">\n<pre><span style=\"color: #993300;\">#include &lt;signal.h&gt;\r\n\r\nint sig2str(int <span class=\"docEmphItalicAlt\">signo<\/span>, char *<span class=\"docEmphItalicAlt\">str<\/span>);\r\n\r\nint str2sig(const char *<span class=\"docEmphItalicAlt\">str<\/span>, int *<span class=\"docEmphItalicAlt\">signop<\/span>);\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td class=\"docTableCell\" align=\"right\" valign=\"top\">\n<p class=\"docText\">Both return: 0 if OK, 1 on error<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f53\u5199\u4ea4\u4e92\u7a0b\u5e8f\u9700\u8981\u63a5\u53d7\u548c\u6253\u5370\u4fe1\u53f7\u540d\u548c\u4fe1\u53f7\u53f7\u65f6\u8fd9\u4e9b\u51fd\u6570\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p><span style=\"color: #993300;\">sig2str<\/span>\u51fd\u6570\u8f6c\u6362\u4fe1\u53f7\u53f7\u5230\u5b57\u7b26\u4e32\u5e76\u5728\u5185\u5b58\u4e2d\u5b58\u50a8\u7ed3\u679c\uff0c\u7531<em>str<\/em>\u6307\u5411\u3002\u8c03\u7528\u8005\u5fc5\u987b\u786e\u8ba4\u5185\u5b58\u8db3\u591f\u5927\uff0c\u80fd\u591f\u5b58\u4e0b\u6700\u5927\u5b57\u7b26\u957f\u5ea6\u548c\u7ed3\u8282\u7684\u7a7a\u5b57\u7b26\u3002Solaris\u5728&lt;signal.h&gt;\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5e38\u91cf<span style=\"color: #993300;\">SIG2STR_MAX<\/span>\u7528\u6765\u5b9a\u4e49\u6700\u5927\u5b57\u7b26\u957f\u5ea6\u3002\u4fe1\u53f7\u540d\u7684\u7ec4\u7a0b\u4e0d\u5305\u542b&#8221;SIG&#8221;\u524d\u7f00\u3002\u4f8b\u5982\uff0c\u4fe1\u53f7<span style=\"color: #993300;\">SIGKILL<\/span>\u8f6c\u6362\u540d\u5b57\u4e3a\u201cKILL\u201d\u5b58\u50a8\u3002<\/p>\n<p><span style=\"color: #993300;\">str2sig<\/span>\u51fd\u6570\u8f6c\u6362\u4fe1\u53f7\u540d\u5230\u4fe1\u53f7\u53f7\u3002\u4fe1\u53f7\u53f7\u4f7f\u7528\u6574\u578b\u53d8\u91cf\u4fdd\u5b58\uff0c\u7531\u6307\u9488<em>signop<\/em>\u6307\u5411\u3002\u4fe1\u53f7\u540d\u53ef\u4ee5\u662f\u6ca1\u6709\u201cSIG\u201d\u524d\u7f00\u7684\u540d\u5b57\u6216\u5341\u8fdb\u5236\u4fe1\u53f7\u53f7\u7684\u5b57\u7b26\u63cf\u8ff0\uff08\u4e5f\u5c31\u662f\u201c9\u201d\u8fd9\u6837\uff09\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u60ef\u4f8b\u4e0d\u4f7f\u7528<span style=\"color: #993300;\">sig2str<\/span>\u548c<span style=\"color: #993300;\">str2sig<\/span>\u5e76\u4e14\u5f53\u5b83\u4eec\u5931\u8d25\u540e\u5e76\u4e0d\u8bbe\u7f6e<span style=\"color: #993300;\">errno<\/span>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8fd9\u8282\uff0c\u6211\u4eec\u63cf\u8ff0\u4e00\u4e9b\u4f9d\u8d56\u4e8e\u5177\u4f53\u5b9e\u73b0\u7684\u9644\u52a0\u4fe1\u53f7\u529f\u80fd\u3002 \u4fe1\u53f7\u540d \u4e00\u4e9b\u7cfb\u7edf\u63d0\u4f9b\u4e86\u6570\u7ec4 extern char *sys_siglist[]; \u6570\u7ec4\u7684\u7d22\u5f15\u662f\u4fe1\u53f7\u53f7\uff0c\u901a\u8fc7&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=744\"> 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-744","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/744","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=744"}],"version-history":[{"count":3,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/744\/revisions"}],"predecessor-version":[{"id":756,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/744\/revisions\/756"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}