• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Jiwu Bu

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              32 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks
             1 #include <unistd.h>
             2 #include <sys/types.h>
             3 #include <stdio.h>
             4 #include <string.h>
             5 #include <errno.h>
             6 
             7 int main(int argc ,char* argv[])
             8 {
             9     pid_t my_pid = getpid();
            10     pid_t parent_pid = getppid();
            11 
            12     printf("ProcessID =%ld  ParentID =%ld\n", my_pid, parent_pid);
            13 
            14     pid_t child = fork();
            15 
            16     printf("-------------------------------------\n");
            17     printf("Fork Process ID = %ld \n", child );
            18 
            19     switch( child )
            20     {
            21         case -1:
            22                printf("Create my child process error by fork func, errno=%ld\n", strerror(errno) );
            23                break;
            24 
            25         case 0:
            26               printf("This is child process! Process ID = %ld\n", getpid() );
            27               break;
            28 
            29         default:
            30               printf("This is not child process! Process ID= %ld Child Process ID=%ld\n", getpid(), child);
            31                
            32     }
            33     
            34     printf("who am I? Process ID=%ld  Parent Process ID= %ld\n", getpid(), getppid());
            35 
            36     return 0;
            37 }
            38 

            運行結果[swallow@localhost syspr]$ ./process
            ProcessID =1182  ParentID =1090
            -------------------------------------
            Fork Process ID = 0
            This is child process! Process ID = 1183
            who am I? Process ID=1183  Parent Process ID= 1182
            -------------------------------------
            Fork Process ID = 1183
            This is not child process! Process ID= 1182 Child Process ID=1183
            who am I? Process ID=1182  Parent Process ID= 1090
            [swallow@localhost syspr]$

            http://m.shnenglu.com/Files/bujiwu/fork.rar

            posted on 2009-09-13 20:25 bujiwu 閱讀(303) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            久久久无码精品亚洲日韩京东传媒| 精品久久久久久| 欧美日韩成人精品久久久免费看| 久久狠狠爱亚洲综合影院| 老男人久久青草av高清| 久久久精品人妻一区二区三区蜜桃 | 久久99国产亚洲高清观看首页| 精品久久久久久久| 伊人色综合久久天天网| 久久99精品久久久久久| 狠狠色婷婷久久综合频道日韩| 97久久精品人妻人人搡人人玩| 日韩亚洲国产综合久久久| 久久久久人妻一区精品性色av| 久久久久久久综合日本| 久久国产精品成人影院| 国产成人久久精品一区二区三区| 狠狠精品干练久久久无码中文字幕| 亚洲欧美久久久久9999| 91麻豆精品国产91久久久久久| 国产人久久人人人人爽| 亚洲∧v久久久无码精品| 亚洲Av无码国产情品久久| 国产一区二区精品久久岳| 99国产精品久久久久久久成人热| 国产亚洲精品久久久久秋霞| 一本久道久久综合狠狠躁AV| 精品国产乱码久久久久久浪潮| 97久久超碰国产精品2021| 亚洲乱码精品久久久久..| 亚洲人成网亚洲欧洲无码久久 | 久久精品人人槡人妻人人玩AV| 久久人人爽人人澡人人高潮AV | 狠狠色丁香婷婷久久综合五月| 一本色综合网久久| 曰曰摸天天摸人人看久久久| 久久久黄色大片| 人妻丰满AV无码久久不卡| 久久国产精品成人影院| 999久久久无码国产精品| 国产精品久久精品|