{"id":535,"date":"2016-10-13T15:25:30","date_gmt":"2016-10-13T07:25:30","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=535"},"modified":"2016-12-01T15:27:19","modified_gmt":"2016-12-01T07:27:19","slug":"shell%e6%89%a7%e8%a1%8c%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=535","title":{"rendered":"SHELL\u6267\u884c\u7a0b\u5e8f"},"content":{"rendered":"<p>\u8ba9\u6211\u4eec\u770b\u4e00\u4e0bshell\u5982\u4f55\u6267\u884c\u7a0b\u5e8f\uff0c\u5e76\u4e14\u4e86\u89e3\u4e00\u4e0b\u5b83\u548c\u8fdb\u7a0b\u7ec4\u7684\u6982\u5ff5\u3001\u63a7\u5236\u7ec8\u7aef\u548c\u4f1a\u8bdd\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u8981\u4e86\u89e3\u8fd9\u4e9b\u6211\u4eec\u5c31\u8981\u4f7f\u7528<span style=\"color: #993300;\">ps<\/span>\u547d\u4ee4\u3002<\/p>\n<p>\u9996\u5148\uff0c \u5728\u4e0dsolaris\u4e0a\u8fd0\u884c\u4e0d\u652f\u6301\u4efb\u52a1\u63a7\u5236\u7684Bourne shell\u3002\u5982\u679c\u6211\u4eec\u6267\u884c\uff1a<\/p>\n<p><span style=\"color: #993300;\">ps -o pid,ppid,pgid,sid,comm<\/span><\/p>\n<p>\u8f93\u51fa\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;\">     PID  PPID  PGID  SID  COMMAND\r\n     949   947   949  949  sh\r\n    1774   949   949  949  ps\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>ps\u7684\u7236\u8fdb\u7a0b\u662fshell\uff0c\u8fd9\u548c\u6211\u4eec\u9884\u8ba1\u7684\u4e00\u6837\u3002shell\u548c<span style=\"color: #993300;\">ps<\/span>\u547d\u4ee4\u90fd\u5728\u540c\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\uff0c\u5e76\u4e14\u90fd\u5728\u540c\u4e00\u4e2a\u524d\u53f0\u8fdb\u7a0b\u7ec4\uff08949\uff09\u4e2d\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u5728\u540e\u53f0\u6267\u884c\u8fd9\u6761\u547d\u4ee4\uff1a<\/p>\n<p><span style=\"color: #993300;\">ps -o pid,ppid,pgid,sid,comm &amp;<\/span><\/p>\n<p>\u552f\u4e00\u6539\u53d8\u7684\u503c\u662f\u8fdb\u7a0bID\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;\">        PID  PPID  PGID  SID COMMAND\r\n        949   947   949  949 sh\r\n       1812   949   949  949 ps\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e2ashell\u5e76\u4e0d\u77e5\u9053\u4efb\u52a1\u63a7\u5236\uff0c\u6240\u4ee5\u540e\u53f0\u4efb\u52a1\u6ca1\u6709\u8fdb\u5165\u5b83\u81ea\u5df1\u7684\u8fdb\u7a0b\u7ec4\u4e2d\uff0c\u5e76\u4e14\u63a7\u5236\u7ec8\u7aef\u6ca1\u6709\u79bb\u5f00\u540e\u53f0\u4efb\u52a1\u3002<\/p>\n<p>\u73b0\u5728\u770b\u4e00\u4e0bBourne shell\u5982\u4f55\u5904\u7406\u7ba1\u9053\uff0c\u5f53\u6211\u4eec\u6267\u884c\uff1a<\/p>\n<p><span style=\"color: #993300;\">ps -o pid,ppid,pgid,sid,comm | cat<\/span><\/p>\n<p>\u8f93\u51fa\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;\">    PID  PPID  PGID  SID COMMAND\r\n    949   947   949  949 sh\r\n   1823   949   949  949 cat1\r\n   1824  1823   949  949 ps\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uff08cat1\u53ea\u662f\u6807\u51c6<span style=\"color: #993300;\">cat<\/span>\u7a0b\u5e8f\u7528\u4e86\u4e0d\u540c\u540d\u5b57\u7684\u4e00\u4e2a\u62f7\u8d1d\uff0c\u5982\u679c\u6709\u5176\u5b83\u62f7\u8d1d\uff0c\u5c31\u4f1a\u51fa\u73b0cat2\uff09\u6ce8\u610f<span style=\"color: #993300;\">cat<\/span>\u662fshell\u7684\u5b50\u8fdb\u7a0b\uff0c\u5e76\u4e14<span style=\"color: #993300;\">ps<\/span>\u662f<span style=\"color: #993300;\">cat<\/span>\u7684\u5b50\u8fdb\u7a0b\u3002\u5b83\u770b\u8d77\u6765\u662fshell <span style=\"color: #993300;\">fork<\/span>\u4e86\u4e00\u4e2a\u5b83\u81ea\u5df1\u7684\u62f7\u8d1d\uff0c\u5e76\u4e14\u8fd9\u4e2a\u62f7\u8d1d\u53c8<span style=\"color: #993300;\">fork<\/span>\u4e86\u7ba1\u9053\u7b26\u53f7\u4e4b\u524d\u6bcf\u4e00\u4e2a\u8fdb\u7a0b\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u5728\u540e\u53f0\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7ba1\u9053\u7b26\u53f7\uff1a<\/p>\n<p><span style=\"color: #993300;\">ps -o pid,ppid,pgid,sid,comm | cat1 &amp;<\/span><\/p>\n<p>\u53ea\u6709\u8fdb\u7a0bID\u6539\u53d8\u3002\u56e0\u4e3ashell\u4e0d\u5904\u7406\u4efb\u52a1\u63a7\u5236\uff0c\u540e\u53f0\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u7ec4ID\u4fdd\u7559\u4e86949\uff0c\u505a\u4e3a\u4f1a\u8bdd\u7684\u8fdb\u7a0b\u7ec4ID\u3002<\/p>\n<p>\u5982\u679c\u540e\u53f0\u8fdb\u7a0b\u5c1d\u8bd5\u4ece\u63a7\u5236\u7ec8\u7aef\u8bfb\u53d6\u6570\u636e\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u4f8b\u5982\uff0c\u6211\u4eec\u6267\u884c\uff1a<\/p>\n<p><span style=\"color: #993300;\">cat &gt; temp.foo &amp;<\/span><\/p>\n<p>\u5728\u6709\u4efb\u52a1\u63a7\u5236\u65f6\uff0c\u4f1a\u628a\u540e\u53f0\u4efb\u52a1\u653e\u5165\u540e\u53f0\u8fdb\u7a0b\u7ec4\uff0c\u5982\u679c\u540e\u53f0\u8fdb\u7a0b\u5c1d\u8bd5\u8bfb\u53d6\u63a7\u5236\u7ec8\u7aef\uff0c\u5b83\u4f1a\u5bfc\u81f4\u4ea7\u751f\u4e00\u4e2a<span style=\"color: #993300;\">SIGTTIN<\/span>\u4fe1\u53f7\u3002\u5728\u6ca1\u6709\u4efb\u52a1\u63a7\u5236\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u8fdb\u7a0b\u6ca1\u6709\u91cd\u5b9a\u5411\u81ea\u5df1\u7684\u6807\u51c6\u8f93\u5165\uff0c\u90a3\u4e48shell\u81ea\u52a8\u5730\u91cd\u5b9a\u5411\u540e\u53f0\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u5165\u5230<span style=\"color: #993300;\">\/dev\/null<\/span>\u3002\u4ece\/dev\/null\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u4f1a\u5f97\u5230\u6587\u4ef6\u7ed3\u5c3e\u6807\u8bb0\u3002<span style=\"text-decoration: underline;\">\u8fd9\u610f\u5473\u7740\u6211\u4eec\u7684\u540e\u53f0cat\u8fdb\u7a0b\u4f1a\u7acb\u5373\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\u7ed3\u5c3e\u5e76\u7ed3\u675f\u3002<\/span><\/p>\n<p>\u4e0a\u9762\u63cf\u8ff0\u7684\u662f\u901a\u8fc7\u6807\u51c6\u8f93\u5165\u7684\u65b9\u5f0f\uff0c\u5982\u679c\u540e\u53f0\u8fdb\u7a0b\u6307\u5b9a\u6253\u5f00<span style=\"color: #993300;\">\/dev\/tty<\/span>\uff0c\u5e76\u4ece\u63a7\u5236\u7ec8\u7aef\u4e2d\u8bfb\u53d6\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u7b54\u6848\u662f\u201c\u770b\u60c5\u51b5\u201d\uff0c\u4f46\u901a\u5e38\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff1a<\/p>\n<p><span style=\"color: #993300;\">crypt &lt; salaries | lpr &amp;<\/span><\/p>\n<p>\u5728\u540e\u53f0\u8fd0\u884c\u5b83\uff0c\u4f46<span style=\"color: #993300;\">crypt<\/span>\u7a0b\u5e8f\u6253\u5f00<span style=\"color: #993300;\">\/dev\/tty<\/span>\uff0c\u6539\u53d8\u7ec8\u7aef\u7279\u6027\uff08\u5173\u95ed\u53cd\u9988(to disable echoing)\uff09\uff0c\u4ece\u8bbe\u5907\u8bfb\u53d6\uff0c\u5e76\u91cd\u7f6e\u7ec8\u7aef\u7279\u6027\u3002\u5f53\u6211\u4eec\u5728\u540e\u53f0\u6267\u884c\u8fd9\u4e2a\u7ba1\u9053\u7b26\u53f7\uff08pipeline\uff09\u65f6\uff0c\u6765\u81ea<span style=\"color: #993300;\">crypt<span style=\"color: #000000;\">\u7a0b\u5e8f<\/span><\/span>\u7684\u201c<span style=\"color: #993300;\">Password:<\/span>\u201d\u63d0\u793a\u4f1a\u88ab\u6253\u5370\u5230\u7ec8\u7aef\u4e0a\uff0c\u4f46\u662f\u6211\u4eec\u5411shell\u8f93\u5165\u4efb\u4f55\u4e1c\u897f\uff0c\u5b83\u90fd\u4f1a\u628a\u8f93\u5165\u5f53\u505a\u547d\u4ee4\u7684\u540d\u5b57\u6765\u6267\u884c\u3002\u4e0b\u4e00\u884c\u6211\u4eec\u7684\u8f93\u5165\u4f1a\u88abshell\u5f53\u505a\u5bc6\u7801\u6765\u4f7f\u7528\uff0c\u5e76\u4e14\u6ca1\u6709\u6b63\u786e\u52a0\u5bc6\uff0c\u518d\u53d1\u9001\u4e00\u4e9b\u6ca1\u7528\u7684\u4e1c\u897f\u5230\u6253\u5370\u673a\u3002\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u4e24\u4e2a\u8fdb\u7a0b\u5728\u540c\u4e00\u65f6\u523b\u8bfb\u53d6\u540c\u4e00\u8bbe\u5907\uff0c\u8fd9\u4e2a\u7ed3\u679c\u4f9d\u8d56\u7cfb\u7edf\u3002\u50cf\u4e4b\u524d\u63cf\u8ff0\u7684\u4efb\u52a1\u63a7\u5236\uff0c\u5b83\u5584\u4e8e\u5904\u7406\u8fd9\u7c7b\u95ee\u9898\u3002<\/p>\n<p>\u56de\u5230\u6211\u4eecBourne shell\u7684\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u6211\u4eec\u5728\u7ba1\u9053\u7b26\u4e2d\u6267\u884c\u4e09\u4e2a\u8fdb\u7a0b\uff0c\u53ef\u4ee5\u8003\u9a8c\u8fd9\u4e2ashell\u7684\u8fdb\u7a0b\u63a7\u5236\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;\">ps -o pid,ppid,pgid,sid,comm | cat1 | cat2\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4ea7\u751f\u4e0b\u9762\u7684\u8f93\u51fa\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;\">     PID  PPID  PGID  SID COMMAND\r\n     949   947   949  949 sh\r\n    1988   949   949  949 cat2\r\n    1989  1988   949  949 ps\r\n    1990  1988   949  949 cat1<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u610f\uff1a\u5728\u7ba1\u9053\u7b26\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u8fdb\u7a0b\u662fshell\u7684\u5b50\u8fdb\u7a0b\uff0c\u5728\u5b83\u4e4b\u524d\u7684\u8fdb\u7a0b\u90fd\u662f\u8be5\u8fdb\u7a0b\u7684\u5b50\u8fdb\u7a0b\u3002\u4e0b\u56fe\u6240\u793a\u53d1\u751f\u4e86\u4ec0\u4e48\u3002\u56e0\u4e3a\u5728\u7ba1\u9053\u7b26\u4e2d\u6700\u540e\u4e00\u4e2a\u8fdb\u7a0b\u662f\u767b\u9646shell\u7684\u5b50\u8fdb\u7a0b\uff0c\u6240\u4ee5\u5728\u5b83\u7ed3\u675f\u65f6\u4f1a\u901a\u77e5shell\u5b83\u5df2\u7ecf\u7ed3\u675f\u4e86\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-543\" src=\"http:\/\/blog.5x44.cn\/wp-content\/uploads\/2016\/10\/figure9.9.jpg\" alt=\"figure9-9\" width=\"731\" height=\"370\" srcset=\"https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/10\/figure9.9.jpg 731w, https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/10\/figure9.9-300x152.jpg 300w, https:\/\/www.5x44.cn\/wp-content\/uploads\/2016\/10\/figure9.9-533x270.jpg 533w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/p>\n<p>\u73b0\u5728\u8ba9\u6211\u4eec\u5728linux\u4e0a\u4f7f\u7528\u5e26\u4efb\u52a1\u63a7\u5236\u7684shell\u6d4b\u8bd5\u4e00\u4e0b\u540c\u6837\u7684\u4f8b\u5b50\u3002\u8fd9\u663e\u793a\u4e86\u8fd9\u4e9bshell\u5904\u7406\u540e\u53f0\u4efb\u52a1\u7684\u65b9\u6cd5\u3002\u6211\u4eec\u5c06\u4f1a\u4f7f\u7528Bourne-again shell\uff1b\u7ed3\u679c\u548c\u5176\u5b83\u4efb\u52a1\u63a7\u5236\u7684shell\u76f8\u540c\u3002<\/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;\">ps -o pid,ppid,pgrp,session,tpgid,comm\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8f93\u51fa\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;\">     PID  PPID  PGRP  SESS  <strong>TPGID<\/strong> COMMAND\r\n    2837  2818  2837  2837   <strong>5796<\/strong> bash\r\n    <strong><span class=\"docEmphStrong\">5796<\/span><\/strong>  2837  <strong><span class=\"docEmphStrong\">5796<\/span><\/strong>  2837   <strong>5796<\/strong> ps<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uff08\u524d\u53f0\u8fdb\u7a0b\u4f7f\u7528\u4e86\u7c97\u5b57\u4f53\uff09\u6211\u4eec\u7acb\u523b\u5f97\u5230\u4e86\u548cBourne shell\u4e0d\u540c\u7684\u7ed3\u679c\u3002Bourne-again shell\u628a\u524d\u53f0\u4efb\u52a1\uff08<span style=\"color: #993300;\">ps<\/span>\uff09\u653e\u5230\u5b83\u81ea\u5df1\u7684\u8fdb\u7a0b\u7ec4\u4e2d\uff08<span style=\"color: #993300;\">5796<\/span>\uff09\u3002<span style=\"color: #993300;\">ps<\/span>\u547d\u4ee4\u662f\u201c\u8fdb\u7a0b\u7ec4\u957f\u201d\u5e76\u4e14\u662f\u8be5\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u552f\u4e00\u8fdb\u7a0b\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u56e0\u4e3a\u5b83\u6709\u63a7\u5236\u7ec8\u7aef\uff0c\u6240\u4ee5\u8fd9\u4e2a\u8fdb\u7a0b\u7ec4\u662f\u524d\u53f0\u8fdb\u7a0b\u7ec4\u3002\u5f53\u6267\u884c<span style=\"color: #993300;\">ps<\/span>\u547d\u4ee4\u65f6\u6211\u4eec\u7684\u767b\u9646shell\u662f\u540e\u53f0\u8fdb\u7a0b\u7ec4\u3002\u6ce8\u610f\uff1a\u4e24\u4e2a\u8fdb\u7a0b\u7ec42837\u548c5796\u90fd\u662f\u540c\u4e00\u4f1a\u8bdd\u7684\u6210\u5458\u3002\u5b9e\u9645\u4e0a\uff0c\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u91cc\uff0c\u5728\u8fd9\u4e2a\u4f1a\u8bdd\u4e2d\u4f1a\u8bdd\u662f\u4e0d\u4f1a\u6539\u53d8\u7684\u3002<\/p>\n<p>\u5728\u540e\u53f0\u6267\u884c\u8fd9\u4e2a\u8fdb\u7a0b\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;\">ps -o pid,ppid,pgrp,session,tpgid,comm &amp;\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c06\u4f1a\u8f93\u51fa\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;\">     PID  PPID  PGRP  SESS  <strong>TPGID<\/strong> COMMAND\r\n    <strong><span class=\"docEmphStrong\">2837<\/span><\/strong>  2818  <strong><span class=\"docEmphStrong\">2837<\/span><\/strong>  2837   <strong>2837<\/strong> bash\r\n    5797  2837  5797  2837   <strong>2837<\/strong> ps\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>ps\u547d\u4ee4\u5728\u5b83\u81ea\u5df1\u7684\u8fdb\u7a0b\u7ec4\u4e2d\uff0c\u4f46\u8fd9\u6b21\u8fdb\u7a0b\u7ec4\uff085797\uff09\u4e0d\u518d\u662f\u524d\u53f0\u8fdb\u7a0b\u7ec4\u4e86\u3002\u5b83\u662f\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u7ec4\u3002<span style=\"color: #993300;\">TPGID<\/span>\u76842837\u6307\u51fa\u524d\u53f0\u8fdb\u7a0b\u7ec4\u662f\u6211\u4eec\u7684\u767b\u9646SHELL\u3002<\/p>\n<p>\u5728\u7ba1\u9053\u7b26\u4e2d\u6267\u884c\u4e24\u4e2a\u8fdb\u7a0b\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;\">ps -o pid,ppid,pgrp,session,tpgid,comm | cat1\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c06\u4f1a\u8f93\u51fa\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;\">     PID  PPID  PGRP  SESS  TPGID COMMAND\r\n    2837  2818  2837  2837   5799 bash\r\n    <strong><span class=\"docEmphStrong\">5799<\/span><\/strong>  2837  <strong><span class=\"docEmphStrong\">5799<\/span><\/strong>  2837   5799 ps\r\n    <strong><span class=\"docEmphStrong\">5800<\/span><\/strong>  2837  <strong><span class=\"docEmphStrong\">5799<\/span><\/strong>  2837   5799 cat1<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #993300;\">ps<\/span>\u548c<span style=\"color: #993300;\">cat1<\/span>\u8fd9\u4e24\u4e2a\u8fdb\u7a0b\u90fd\u5728\u65b0\u7684\u8fdb\u7a0b\u7ec4\uff085799\uff09\u4e2d\uff0c\u5e76\u4e14\u8fd9\u6b21\u662f\u5728\u524d\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\u3002\u80fd\u5728\u672c\u4f8b\u548cBourne Shell\u7684\u4f8b\u5b50\u4e2d\u627e\u5230\u4e00\u4e9b\u4e0d\u540c\u4e4b\u5904\u3002Bourne Shell\u5728\u7ba1\u9053\u7b26\u4e2d\u5148\u521b\u5efa\u4e86\u6700\u540e\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u800c\u6700\u540e\u4e00\u4e2a\u8fdb\u7a0b\u662f\u7b2c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b\u3002\u8fd9\u91ccBourne-again Shell\u662f\u4e24\u4e2a\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b\u3002\u5982\u679c\u6211\u4eec\u5728\u7ba1\u9053\u4e2d\u6267\u884c\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;\">ps -o pid,ppid,pgrp,session,tpgid,comm | cat1 &amp;\r\n<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ed3\u679c\u662f\u4e00\u6837\u7684\uff0c\u53ea\u662f<span style=\"color: #993300;\">ps<\/span>\u548c<span style=\"color: #993300;\">cat1<\/span>\u5728\u540c\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u7ec4\u4e2d\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;\">     PID  PPID  PGRP  SESS  TPGID COMMAND\r\n    <strong><span class=\"docEmphStrong\">2837<\/span><\/strong>  2818  <strong><span class=\"docEmphStrong\">2837<\/span><\/strong>  2837   2837 bash\r\n    5801  2837  5801  2837   2837 ps\r\n    5802  2837  5801  2837   2837 cat1<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u610f\uff1a\u987a\u5e8f\u53ef\u80fd\u4f1a\u6839\u636e\u4e0d\u540c\u7684shell\u6709\u6240\u4e0d\u540c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba9\u6211\u4eec\u770b\u4e00\u4e0bshell\u5982\u4f55\u6267\u884c\u7a0b\u5e8f\uff0c\u5e76\u4e14\u4e86\u89e3\u4e00\u4e0b\u5b83\u548c\u8fdb\u7a0b\u7ec4\u7684\u6982\u5ff5\u3001\u63a7\u5236\u7ec8\u7aef\u548c\u4f1a\u8bdd\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u8981\u4e86\u89e3\u8fd9\u4e9b\u6211\u4eec\u5c31\u8981\u4f7f\u7528ps\u547d\u4ee4\u3002 \u9996\u5148\uff0c \u5728\u4e0dsolaris\u4e0a\u8fd0\u884c\u4e0d&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=535\"> 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-535","post","type-post","status-publish","format-standard","hentry","category-apue"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/535","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=535"}],"version-history":[{"count":11,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/535\/revisions"}],"predecessor-version":[{"id":547,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/535\/revisions\/547"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}