{"id":284,"date":"2011-12-10T21:56:00","date_gmt":"2011-12-10T13:56:00","guid":{"rendered":"http:\/\/ykyi.net\/?p=284"},"modified":"2011-12-10T21:56:00","modified_gmt":"2011-12-10T13:56:00","slug":"unix%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b-%e7%ac%ac%e4%ba%94%ef%bc%8c%e5%85%ad%e7%ab%a0%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=284","title":{"rendered":"Unix\u7f51\u7edc\u7f16\u7a0b.\u7b2c\u4e94\uff0c\u516d\u7ae0\u7b14\u8bb0."},"content":{"rendered":"<p># Unix\u4e16\u754c\u91cc\u7ecf\u5e38\u770b\u5230\u7684 pst&nbsp; \u662f pseudo terminal \u7684\u610f\u601d\u554a\u3002<\/p>\n<p># ps -t pts\/6 -o pid,ppid,tty,stat,args,wchan<\/p>\n<p>ps \u547d\u4ee4\u7684\u8fdb\u7a0b\u72b6\u6001\u3002 S\u8868\u793a\u8fdb\u7a0b\u5728\u7761\u7720\uff0cI\u8868\u793a\u8fdb\u7a0b\u5728\u7b49\u5f85\u8f93\u5165\uff0cO\u8868\u793a\u8fdb\u7a0b\u5728\u7b49\u5f85\u8f93\u51fa\u3002\u5f53\u8fdb\u7a0b\u5728S\u72b6\u6001\u65f6\uff0cwlan\u6307\u793a\u4e86\u66f4\u8be6\u7ec6\u7684\u72b6\u6001\u4fe1\u606f\u3002<\/p>\n<p># SIGSTOP \u548c SIGKILL \u4e24\u4e2aposix\u4fe1\u53f7\u4e0d\u53ef\u4ee5\u88abcaught.<\/p>\n<p># \u7f3a\u7701\u60c5\u51b5\u4e0b\uff0cUnix\u7684\u4fe1\u53f7\u662f\u4e0d\u6392\u5728\u961f\u5217\u4e2d\u7684\u3002\u8fd9\u610f\u5473\u7740\u591a\u4e2a\u76f8\u540csignal\u5230\u8fbe\u7684\u65f6\u5019\u5982\u679c\u6ca1\u6709\u6765\u5f97\u53ca\u5904\u7406\uff0c\u5c31\u53ea\u4f1a\u8bb0\u4e0b\u4e00\u4e2asignal.\u5982\u679c\u9700\u8981\u7a33\u5b9a\u7684\u4fe1\u53f7\u652f\u6301\uff0c\u5c31\u8981\u4f7f\u7528RealTime Posix\u63a5\u53e3\u3002<\/p>\n<p># init \u8fdb\u7a0b\u7684PID\u662f 1.<\/p>\n<p># \u53ef\u4ee5\u7528sigprocmask\u51fd\u6570block\u548cunblock\u4fe1\u53f7\u3002This let us protect a critical region of code by preventing certain signals from being caught while that region of code is executing.<\/p>\n<p># \u5bf9\u4e8e Unix System V \u548c Unix98, the child of a process does not become a zombie if the process sets the disposition of SIGCHLD to SIG_IGN. unfortunately, tis works only under System V &amp; Unix98. Posix\u660e\u786e\u6307\u7968\u8fd9\u4e2a\u884c\u4e3a\u662f\u672a\u5b9a\u4e49\u7684\u3002The portable way to handle zombies is to catch SIGCHILD &amp; call wait or waitpid.<\/p>\n<p># waitpid \u6709\u4e2a WNOHANG \u9009\u9879\u53ef\u4ee5\u8ba9waitpid\u7acb\u5373\u8fd4\u56de\u3002<\/p>\n<p># POSIX\u5b9a\u4e49\u4e86asynchronous I\/O model .\u4f46\u662f few systems support POSIX asynchronous I\/O. The main difference between asynchronous I\/O model and signal-driven I\/O model is that with signal-driven I\/O, the kernel tells us when an I\/O operation can be initiated but with asynchronous I\/O, the kernel tells us when an I\/O operation is completed.<\/p>\n<p># \u60f3\u5f97\u5230\u672c\u673a\u5230\u67d0\u53f0\u673a\u7684RTT\u3002\u600e\u4e48\u505a\u5462\uff1fkao,\u4e0d\u8981\u592a\u5bb9\u6613\u554a\u3002\u7528 ping \u554a\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Unix\u4e16\u754c\u91cc\u7ecf\u5e38\u770b\u5230\u7684 pst&nbsp; \u662f pseudo terminal \u7684\u610f\u601d\u554a\u3002 # ps -t pts\/6 -o pid,ppid,tty,stat,args,wchan ps \u547d\u4ee4\u7684\u8fdb\u7a0b\u72b6\u6001\u3002 S\u8868\u793a\u8fdb\u7a0b\u5728\u7761\u7720\uff0cI\u8868\u793a\u8fdb\u7a0b\u5728\u7b49\u5f85\u8f93\u5165\uff0cO\u8868\u793a\u8fdb\u7a0b\u5728\u7b49\u5f85\u8f93\u51fa\u3002\u5f53\u8fdb\u7a0b\u5728S\u72b6\u6001\u65f6\uff0cwlan\u6307\u793a\u4e86\u66f4\u8be6\u7ec6\u7684\u72b6\u6001\u4fe1\u606f\u3002 # SIGSTOP \u548c SIGKILL \u4e24\u4e2aposix\u4fe1\u53f7\u4e0d\u53ef\u4ee5\u88abcaught. # \u7f3a\u7701\u60c5\u51b5\u4e0b\uff0cUnix\u7684\u4fe1\u53f7\u662f\u4e0d\u6392\u5728\u961f\u5217\u4e2d\u7684\u3002\u8fd9\u610f\u5473\u7740\u591a\u4e2a\u76f8\u540csignal\u5230\u8fbe\u7684\u65f6\u5019\u5982\u679c\u6ca1\u6709\u6765\u5f97\u53ca\u5904\u7406\uff0c\u5c31\u53ea\u4f1a\u8bb0\u4e0b\u4e00\u4e2asignal.\u5982\u679c\u9700\u8981\u7a33\u5b9a\u7684\u4fe1\u53f7\u652f\u6301\uff0c\u5c31\u8981\u4f7f\u7528RealTime Posix\u63a5\u53e3\u3002 # init \u8fdb\u7a0b\u7684PID\u662f 1. # \u53ef\u4ee5\u7528sigprocmask\u51fd\u6570block\u548cunblock\u4fe1\u53f7\u3002This let us protect a critical region of code by preventing certain signals from being caught while that region of code is executing. # \u5bf9\u4e8e Unix &hellip; <a href=\"https:\/\/ykyi.net\/?p=284\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Unix\u7f51\u7edc\u7f16\u7a0b.\u7b2c\u4e94\uff0c\u516d\u7ae0\u7b14\u8bb0.&#8221;<\/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":[4,6,7],"tags":[81,82,118],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-network","category-tech_articles","category-unix_linux","tag-unix","tag-unix-socket","tag-118"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=284"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/284\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}