• <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>
            隨筆-167  評論-8  文章-0  trackbacks-0
            pipe(建立管道)

            表頭文件 #include<unistd.h>
            定義函數(shù) int pipe(int filedes[2]);
            函數(shù)說明
                pipe()會建立管道,并將文件描述詞由參數(shù) filedes 數(shù)組返回。
                filedes[0]為管道里的讀取端,所以pipe用read調(diào)用的
                filedes[1]則為管道的寫入端。
                
            返回值:  若成功則返回零,否則返回-1,錯誤原因存于 errno 中。
            錯誤代碼:
                EMFILE 進(jìn)程已用完文件描述詞最大量
                ENFILE 系統(tǒng)已無文件描述詞可用。
                EFAULT 參數(shù) filedes 數(shù)組地址不合法。

            #include <unistd.h>
            #include <stdio.h>

            int main( void )
            {
                int filedes[2];
                char buf[80];
                pid_t pid;
               
                pipe( filedes );
               
                if ( (pid=fork()) > 0 )
                {
                    printf( "This is in the father process,here write a string to the pipe.\n" );
                    char s[] = "Hello world , this is write by pipe.\n";
                    write( filedes[1], s, sizeof(s) );
                    close( filedes[0] );
                    close( filedes[1] );
                }
                else
                {
                    printf( "This is in the child process,here read a string from the pipe.\n" );
                    read( filedes[0], buf, sizeof(buf) );
                    printf( "%s\n", buf );
                    close( filedes[0] );
                    close( filedes[1] );
                }
               
                waitpid( pid, NULL, 0 );
               
                return 0;
            }


            [root@localhost src]# gcc pipe.c
            [root@localhost src]# ./a.out
            This is in the child process,here read a string from the pipe.
            This is in the father process,here write a string to the pipe.
            Hello world , this is write by pipe.
            posted on 2010-06-14 18:19 老馬驛站 閱讀(2759) 評論(0)  編輯 收藏 引用 所屬分類: c++linux
            精品久久久久久无码专区不卡| 色噜噜狠狠先锋影音久久| 91精品国产高清久久久久久国产嫩草 | 国产精品久久永久免费| 亚洲国产精品久久久久| 亚洲国产精品无码久久久久久曰| 色青青草原桃花久久综合| 亚洲中文字幕无码久久综合网 | 久久天天躁狠狠躁夜夜躁2O2O| 久久久久久国产精品无码超碰| 国内精品久久久久久久涩爱 | 久久亚洲AV无码精品色午夜| 麻豆成人久久精品二区三区免费| 国产亚洲成人久久| 97久久精品无码一区二区| 色播久久人人爽人人爽人人片aV | 久久久精品一区二区三区| 久久久久久久免费视频| 国产L精品国产亚洲区久久| 亚洲AV日韩精品久久久久久| 久久亚洲2019中文字幕| 精品久久久久久亚洲| 色综合久久中文字幕无码| 亚洲人成无码www久久久 | 无码国产69精品久久久久网站| 久久精品亚洲欧美日韩久久| 精品午夜久久福利大片| 亚洲AV无码久久精品成人| 久久精品无码一区二区WWW| 青青草原1769久久免费播放| 久久久青草久久久青草| 久久精品毛片免费观看| 无码国内精品久久人妻蜜桃| 亚洲国产欧美国产综合久久| 亚洲AV无一区二区三区久久| 亚洲精品乱码久久久久久| 久久亚洲国产成人精品性色| 一本久久a久久精品亚洲| 亚洲国产欧美国产综合久久| 蜜臀av性久久久久蜜臀aⅴ麻豆| 无码精品久久久天天影视|