• <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://www.shnenglu.com/Files/bujiwu/fork.rar

            posted on 2009-09-13 20:25 bujiwu 閱讀(303) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            亚洲成色WWW久久网站| 婷婷综合久久狠狠色99h| 久久久久国产成人精品亚洲午夜| 久久99精品久久久久久久不卡| 性做久久久久久久| 国产精品青草久久久久婷婷| 99热成人精品免费久久| 亚洲va久久久久| 精品水蜜桃久久久久久久| 欧美久久久久久精选9999| 性做久久久久久久| 亚洲国产视频久久| 久久综合日本熟妇| 精品久久久久中文字| 国产成人香蕉久久久久| 久久久久久久久久久久久久 | 热综合一本伊人久久精品| 久久香蕉国产线看观看精品yw| 色偷偷888欧美精品久久久| 久久精品久久久久观看99水蜜桃| 精品无码久久久久久国产| 亚洲精品高清久久| 国产激情久久久久影院老熟女免费 | 亚洲欧美日韩中文久久 | 久久亚洲天堂| 国产三级精品久久| 丰满少妇人妻久久久久久4| av午夜福利一片免费看久久| 久久精品一区二区| 精品久久久无码中文字幕| 7国产欧美日韩综合天堂中文久久久久 | 久久国产精品-久久精品| 欧美久久久久久精选9999| 国内精品久久久久久野外| 99久久精品国内| 久久久久人妻精品一区二区三区 | 99久久精品日本一区二区免费| 久久精品国产99国产电影网 | 久久精品国产精品亚洲下载| 久久午夜无码鲁丝片秋霞 | 无码国内精品久久人妻蜜桃|