• <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 閱讀(294) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            伊人久久国产免费观看视频| 一本久久免费视频| 久久99久久99精品免视看动漫| 99久久精品国产毛片| 久久天堂AV综合合色蜜桃网| 亚洲午夜无码久久久久| 久久久久久国产精品美女| 久久精品国产亚洲AV蜜臀色欲 | 2021最新久久久视精品爱| 久久久人妻精品无码一区| 久久久久国产精品麻豆AR影院| 夜夜亚洲天天久久| 久久久九九有精品国产| 久久av无码专区亚洲av桃花岛| 久久久亚洲欧洲日产国码aⅴ| 久久久久亚洲AV成人片| 久久不见久久见免费视频7| 国产精品美女久久久| 亚洲欧美日韩精品久久| 看全色黄大色大片免费久久久| 久久久高清免费视频| 精品无码久久久久国产动漫3d| 久久精品国产亚洲AV无码麻豆 | 丁香五月网久久综合| 国产精品久久网| 人妻少妇精品久久| yy6080久久| 久久免费精品视频| 久久精品免费一区二区| 天天爽天天爽天天片a久久网| 伊人久久亚洲综合影院| 天堂久久天堂AV色综合| 94久久国产乱子伦精品免费 | 一本一道久久a久久精品综合| 国色天香久久久久久久小说| 国产亚洲精品自在久久| 理论片午午伦夜理片久久| 久久国产色av免费看| 精品久久人人爽天天玩人人妻| 久久午夜羞羞影院免费观看| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 |