{"id":531,"date":"2016-09-28T16:07:08","date_gmt":"2016-09-28T08:07:08","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=531"},"modified":"2016-12-01T15:27:19","modified_gmt":"2016-12-01T07:27:19","slug":"%e4%bb%bb%e5%8a%a1%e6%8e%a7%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=531","title":{"rendered":"\u4efb\u52a1\u63a7\u5236"},"content":{"rendered":"<p>\u4efb\u52a1\u63a7\u5236\u8fd9\u4e2a\u529f\u80fd\u5141\u8bb8\u6211\u4eec\u4ece\u5355\u72ec\u7684\u7ec8\u7aef\u91cc\u5f00\u59cb\u591a\u4e2a\u4efb\u52a1\uff08\u8fdb\u7a0b\u7ec4\uff09\u5e76\u53bb\u63a7\u5236\u8fd9\u4e9b\u4efb\u52a1\u8bbf\u95ee\u7ec8\u7aef\u5e76\u5728\u540e\u53f0\u8fd4\u56de\u4efb\u52a1\u7684\u7ed3\u679c\u3002\u4efb\u52a1\u63a7\u5236\u9700\u8981\u4e09\u79cd\u652f\u6301\u5f62\u5f0f\uff1a<\/p>\n<ol>\n<li>\u4e00\u4e2a\u652f\u6301\u4efb\u52a1\u63a7\u5236\u7684shell<\/li>\n<li>\u7ec8\u7aef\u9a71\u52a8\u5fc5\u987b\u652f\u6301\u4efb\u52a1\u63a7\u5236<\/li>\n<li>\u5185\u6838\u5fc5\u987b\u652f\u6301\u67d0\u4e9b\u4efb\u52a1\u63a7\u5236\u7684\u4fe1\u53f7<\/li>\n<\/ol>\n<p>SHELL\u5e76\u4e0d\u4f1a\u6253\u5370\u51fa\u540e\u53f0\u4efb\u52a1\u72b6\u6001\u6539\u53d8\u7684\u4fe1\u606f\uff0c\u53ea\u6709\u5728\u9700\u8981\u8f93\u5165\u65b0\u7684\u547d\u4ee4\u884c\u65f6\uff0c\u624d\u4f1a\u6253\u5370\u51fa\u63d0\u793a\u3002<\/p>\n<p>\u5728\u548c\u7ec8\u7aef\u9a71\u52a8\u4ea4\u4e92\u65f6\uff0c\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u4f1a\u5f71\u54cd\u524d\u53f0\u4efb\u52a1\uff1a\u5982\u6302\u8d77\u952e\uff08ctrl+z\uff09\u3002\u8fd9\u4e2a\u5b57\u7b26\u4f1a\u8ba9\u7ec8\u7aef\u9a71\u52a8\u53d1\u9001<span style=\"color: #993300;\">SIGTSTP<\/span>\u4fe1\u53f7\u5230\u524d\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\u6240\u6709\u7684\u8fdb\u7a0b\u3002\u6240\u6709\u540e\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u4efb\u52a1\u4e0d\u4f1a\u53d7\u5230\u5f71\u54cd\u3002\u7ec8\u7aef\u9a71\u52a8\u53ef\u4ee5\u8bc6\u522b\u51fa\u4e09\u79cd\u7279\u6b8a\u5b57\u7b26\uff0c\u5b83\u4ea7\u751f\u7684\u4fe1\u53f7\u4f1a\u53d1\u9001\u5230\u524d\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\u3002<\/p>\n<ul>\n<li>\u4e2d\u65ad\u5b57\u7b26\uff08\u4e00\u822c\u662fDELETE\u6216ctrl+c\uff09\u4ea7\u751f<span style=\"color: #993300;\">SIGINT<\/span>\u3002<\/li>\n<li>\u9000\u51fa\u5b57\u7b26\uff08\u4e00\u822c\u662fCTRL+\\\uff09\u4ea7\u751f<span style=\"color: #993300;\">SIGQUIT<\/span>\u3002<\/li>\n<li>\u6302\u8d77\u5b57\u7b26\uff08\u4e00\u822c\u662fCTRL+Z\uff09\u4ea7\u751f<span style=\"color: #993300;\">SIGTSTP<\/span>\u3002<\/li>\n<\/ul>\n<p>\u53ea\u8981\u80fd\u88ab\u7ec8\u7aef\u9a71\u52a8\u5904\u7406\uff0c\u4e5f\u53ef\u4ee5\u4ea7\u751f\u5176\u5b83\u7684\u63a7\u5236\u6761\u4ef6\u3002\u53ea\u6709\u524d\u53f0\u4efb\u52a1\u53ef\u4ee5\u6536\u5230\u7ec8\u7aef\u8f93\u5165\u3002\u5f53\u7ec8\u7aef\u9a71\u52a8\u53d1\u73b0\u540e\u53f0\u4efb\u52a1\u5c1d\u8bd5\u4ece\u7ec8\u7aef\u8bfb\u53d6\u65f6\uff0c\u5b83\u4f1a\u53d1\u9001\u4e00\u4e2a\u7279\u6b8a\u4fe1\u53f7\u7ed9\u540e\u53f0\u4efb\u52a1\uff1a<span style=\"color: #993300;\">SIGTTIN<\/span>\u3002\u8fd9\u4e2a\u4fe1\u53f7\u4e00\u822c\u662f\u505c\u6b62\u540e\u53f0\u4efb\u52a1\uff1b\u901a\u8fc7\u4f7f\u7528SHELL\uff0c\u6211\u4eec\u4f1a\u5f97\u5230\u4e00\u4e2a\u901a\u77e5\uff0c\u5e76\u80fd\u8ba9\u8be5\u4efb\u52a1\u56de\u5230\u524d\u53f0\uff0c\u5982\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;\">   $ <span class=\"docEmphStrong\">cat &gt; temp.foo &amp;<\/span>          <span class=\"docEmphItalicAlt\">start in background, but it'll read from standard input<\/span>\r\n   [1]     1681\r\n   $                           <span class=\"docEmphItalicAlt\">we press RETURN<\/span>\r\n   [1] + Stopped (SIGTTIN)     <span class=\"docEmphStrong\">cat &gt; temp.foo &amp;<\/span>\r\n   $ <span class=\"docEmphStrong\">fg %1<\/span>                     <span class=\"docEmphItalicAlt\">bring job number 1 into the foreground<\/span>\r\n   cat &gt; temp.foo              <span class=\"docEmphItalicAlt\">the shell tells us which job is now in the foreground<\/span>\r\n   <span class=\"docEmphStrong\">\r\n   hello, world<\/span>                <span class=\"docEmphItalicAlt\">enter one line<\/span>\r\n   <strong><span class=\"docEmphStrong\">\r\n   ^D<\/span><\/strong>                          <span class=\"docEmphItalicAlt\">type the end-of-file character<\/span>\r\n   $ <span class=\"docEmphStrong\">cat temp.foo<\/span>              <span class=\"docEmphItalicAlt\">check that the one line was put into the file<\/span>\r\n   hello, world\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>shell\u5728\u540e\u53f0\u5f00\u59cb<span style=\"color: #993300;\">cat<\/span>\u8fdb\u7a0b\uff0c\u4f46\u662f\u5f53cat\u5c1d\u8bd5\u8bfb\u53d6\u5b83\u7684\u6807\u51c6\u8f93\u5165\uff08\u5f53\u524d\u63a7\u5236\u7ec8\u7aef\uff09\u65f6\uff0c\u7ec8\u7aef\u9a71\u52a8\u77e5\u9053\u5b83\u662f\u4e00\u4e2a\u540e\u53f0\u4efb\u52a1\uff0c\u53d1\u9001<span style=\"color: #993300;\">SIGTTIN<\/span>\u4fe1\u53f7\u5230\u540e\u53f0\u4efb\u52a1\u3002shell\u53d1\u73b0\u5b50\u8fdb\u7a0b\u72b6\u6001\u6539\u53d8\uff0c\u5e76\u544a\u8bc9\u6211\u4eec\u8fd9\u4e2a\u4efb\u52a1\u5df2\u7ecf\u505c\u6b62\u3002\u4e4b\u540e\uff0c\u6211\u4eec\u7528<span style=\"color: #993300;\">fg<\/span>\u547d\u4ee4\u628a\u505c\u6b62\u7684\u4efb\u52a1\u79fb\u52a8\u5230\u524d\u53f0\u3002\u8fd9\u4e48\u505a\u4f7f\u5f97shell\u628a\u4efb\u52a1\u653e\u5230\u524d\u53f0\u8fdb\u7a0b\u7ec4\uff08<span style=\"color: #993300;\">tcsetpgrp<\/span>\uff09\uff0c\u5e76\u53d1\u9001\u7ee7\u7eed\u4fe1\u53f7\uff08<span style=\"color: #993300;\">SIGCONT<\/span>\uff09\u5230\u8fdb\u7a0b\u7ec4\u3002\u56e0\u4e3a\u8be5\u4efb\u52a1\u5df2\u7ecf\u5728\u524d\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\uff0c\u6240\u4ee5\u5b83\u80fd\u4ece\u63a7\u5236\u7ec8\u7aef\u4e2d\u8bfb\u53d6\u3002<\/p>\n<p>\u540e\u53f0\u4efb\u52a1\u53d1\u9001\u6570\u636e\u5230\u63a7\u5236\u7ec8\u7aef\u65f6\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u8fd9\u662f\u4e2a\u9009\u9879\uff0c\u6211\u4eec\u53ef\u4ee5\u5141\u8bb8\u4e5f\u53ef\u4ee5\u7981\u6b62\u3002\u4e00\u822c\u6211\u4eec\u7528<span style=\"color: #993300;\">stty<\/span>\u547d\u4ee4\u6539\u53d8\u8fd9\u4e2a\u9009\u9879\u3002\u4e0b\u9762\u663e\u793a\u4e86\u5b83\u662f\u5982\u4f55\u5de5\u4f5c\u7684\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;\">   $ <span class=\"docEmphStrong\">cat temp.foo &amp;<\/span>             <span class=\"docEmphItalicAlt\">execute in background<\/span>\r\n   [1]     1719\r\n   $ hello, world               <span class=\"docEmphItalicAlt\">the output from the background job appears after the prompt<\/span>\r\n                                <span class=\"docEmphItalicAlt\">we press RETURN<\/span>\r\n   [1] + Done              cat temp.foo &amp;\r\n   $ <span class=\"docEmphStrong\">stty tostop<\/span>                <span class=\"docEmphRoman\">disable ability of background jobs to output to\r\n controlling terminal<\/span>\r\n   $ <span class=\"docEmphStrong\">cat temp.foo &amp;<\/span>             <span class=\"docEmphItalicAlt\">try it again in the background<\/span>\r\n   [1]     1721\r\n   $                            <span class=\"docEmphItalicAlt\">we press RETURN and find the job is stopped<\/span>\r\n   [1] + Stopped(SIGTTOU)               cat temp.foo &amp;\r\n   $ <span class=\"docEmphStrong\">fg %1<\/span>                      <span class=\"docEmphItalicAlt\">resume stopped job in the foreground<\/span>\r\n   cat temp.foo                 <span class=\"docEmphItalicAlt\">the shell tells us which job is now in the foreground<\/span>\r\n   hello, world                 <span class=\"docEmphItalicAlt\">and here is its output<\/span>\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f53\u6211\u4eec\u7981\u6b62\u540e\u53f0\u4efb\u52a1\u5411\u63a7\u5236\u7ec8\u7aef\u8f93\u51fa\u65f6\uff0ccat\u5c06\u4f1a\u963b\u585e\u5b83\u8f93\u51fa\u5230\u6807\u51c6\u8f93\u51fa\uff0c\u56e0\u4e3a\u7ec8\u7aef\u9a71\u52a8\u6807\u8bc6\u4e86\u8fd9\u4e2a\u52a8\u4f5c\u6765\u81ea\u540e\u53f0\u8fdb\u7a0b\uff0c\u5e76\u5411\u4efb\u52a1\u53d1\u9001<span style=\"color: #993300;\">SIGTTOU<\/span>\u4fe1\u53f7\u3002\u5c31\u50cf\u4e4b\u524d\u7684\u4f8b\u5b50\u4e00\u6837\uff0c\u4f7f\u7528<span style=\"color: #993300;\">fg<\/span>\u547d\u4ee4\u628a\u4efb\u52a1\u5e26\u5230\u524d\u53f0\uff0c\u4e4b\u540e\u4efb\u52a1\u5b8c\u6210\u6240\u6709\u4efb\u52a1\u3002<\/p>\n<p>\u56fe9.8\u6c47\u603b\u4e86\u4efb\u52a1\u63a7\u5236\u7684\u4e00\u4e9b\u529f\u80fd\u3002\u5728\u7ec8\u7aef\u9a71\u52a8\u5757\u4e2d\u7684\u5b9e\u7ebf\u610f\u5473\u7740\u7ec8\u7aefI\/O(terminal I\/O)\u548c\u7ec8\u7aef\u4ea7\u751f\u7684\u4fe1\u53f7(terminal-generated signals)\u4e00\u76f4\u4ece\u7740\u524d\u53f0\u8fdb\u7a0b\u7ec4\u8fde\u63a5\u5230\u5b9e\u9645\u7ec8\u7aef\u3002\u800c\u865a\u7ebf\u8fde\u63a5\u7684SIGTTOU\u4fe1\u53f7\u610f\u5473\u7740\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u8f93\u5230\u7ec8\u7aef\u7684\u8f93\u51fa\u662f\u53ef\u9009\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-533\" src=\"http:\/\/blog.5x44.cn\/wp-content\/uploads\/2016\/09\/figure9.8.jpg\" alt=\"figure9-8\" width=\"914\" height=\"735\" srcset=\"https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/09\/figure9.8.jpg 914w, https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/09\/figure9.8-300x241.jpg 300w, https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/09\/figure9.8-768x618.jpg 768w, https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/09\/figure9.8-336x270.jpg 336w\" sizes=\"auto, (max-width: 914px) 100vw, 914px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4efb\u52a1\u63a7\u5236\u8fd9\u4e2a\u529f\u80fd\u5141\u8bb8\u6211\u4eec\u4ece\u5355\u72ec\u7684\u7ec8\u7aef\u91cc\u5f00\u59cb\u591a\u4e2a\u4efb\u52a1\uff08\u8fdb\u7a0b\u7ec4\uff09\u5e76\u53bb\u63a7\u5236\u8fd9\u4e9b\u4efb\u52a1\u8bbf\u95ee\u7ec8\u7aef\u5e76\u5728\u540e\u53f0\u8fd4\u56de\u4efb\u52a1\u7684\u7ed3\u679c\u3002\u4efb\u52a1\u63a7\u5236\u9700\u8981\u4e09\u79cd\u652f\u6301\u5f62\u5f0f\uff1a \u4e00\u4e2a\u652f\u6301\u4efb\u52a1\u63a7\u5236\u7684she&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=531\"> 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-531","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/531","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=531"}],"version-history":[{"count":2,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions"}],"predecessor-version":[{"id":534,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions\/534"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}