• <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
            国产精品中文久久久久久久| 久久96国产精品久久久| 性做久久久久久久久老女人 | 亚洲精品WWW久久久久久| 国产69精品久久久久APP下载| 久久亚洲精品无码AV红樱桃| 91精品国产综合久久四虎久久无码一级| 久久黄视频| 久久99国产精品久久久 | 久久久久高潮毛片免费全部播放 | 久久久国产乱子伦精品作者| 狠狠精品干练久久久无码中文字幕 | 久久久人妻精品无码一区| 久久综合久久自在自线精品自| 91麻豆精品国产91久久久久久| 久久亚洲sm情趣捆绑调教| 国产精品内射久久久久欢欢| 国产V综合V亚洲欧美久久| 2021国产精品午夜久久| 亚洲国产成人精品91久久久| 久久国产视屏| 国产ww久久久久久久久久| 99国产欧美精品久久久蜜芽 | 精品久久久久久久久久中文字幕| 伊人久久综合无码成人网| 欧美久久亚洲精品| 国产成人久久久精品二区三区 | 久久丫精品国产亚洲av| 久久久无码精品亚洲日韩京东传媒| 久久久久久极精品久久久| 久久国产精品视频| 国产成人精品久久综合| 丰满少妇人妻久久久久久4| 久久婷婷久久一区二区三区| 女人香蕉久久**毛片精品| 国产精品视频久久久| 99久久国产热无码精品免费| 999久久久免费精品国产| 青青青国产精品国产精品久久久久| 好久久免费视频高清| 97精品国产97久久久久久免费|