• <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>

            Prayer

            在一般中尋求卓越
            posts - 1256, comments - 190, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            This case may relates to stdio buffering.
            If stdout is a terminal, it is line buffered. The buffer is flushed when a new line is hit.
            Otherwise, stdout is fully buffered. The buffer is flushed if the buffer is full or the program terminates.flush means clear the stdout.
            如果終端是標準輸出,它就是行緩存的,當遇到新行符,則被刷新一次。
            如果標準輸出不是中斷,那它是全緩存的。如果緩沖區(qū)滿或者程序被終止,緩沖區(qū)被刷新。


            So
            1) we run bpeek directly, the printf() function is line buffered, when "\n" is hit, the buffer is flushed immediately and "<< output from stdout >>" is printed.
            2) we run bpeek|tail, the printf() functions became fully buffered, when "\n" is hit, the buffer is NOT flushed. The buffer resides in the process's memory. When the process execute fork(), the son gets a copy from the father's memory, that means both father and son process have the unflushed buffer. When the son process exits, the message is printed. When the father exits, the message is printed again.

            We can write a simple program to simulate this:
            ----------------------------
            #include <stdio.h>
            #include <sys/types.h>
            #include <unistd.h>
            int main(){
                    pid_t pid;

                    printf("<< %s >>\n", "output of stdout");
                    pid = fork();

                 if(pid < 0){
                      printf("fork error\n");
                      exit(-1);
                 }else if(pid > 0){
                      wait(NULL);
                      return;
                 }
                 exit(0);
            }


            "To avoid this, we my force printf() to line buffered:
            setvbuf(stdout, buf, _IOLBF, BUFSIZ);"

            久久精品无码一区二区三区| 久久国产免费观看精品3| 国产亚洲美女精品久久久| 亚洲国产精品久久久久婷婷软件| 久久福利片| 99久久精品免费看国产一区二区三区 | 久久精品国产99久久久古代| 久久久久久国产精品无码超碰| 91精品国产高清久久久久久91| 亚洲第一永久AV网站久久精品男人的天堂AV | 97久久精品人人澡人人爽| 人妻中文久久久久| 久久福利青草精品资源站| 狠狠色丁香婷婷久久综合五月| www久久久天天com| 日产久久强奸免费的看| www久久久天天com| 综合网日日天干夜夜久久| 伊人色综合久久| 狠狠色婷婷久久一区二区三区| 少妇久久久久久被弄到高潮| 国产精品久久久久国产A级| 中文字幕久久亚洲一区| 一级做a爰片久久毛片人呢| 久久久久久毛片免费播放| 综合久久一区二区三区 | 欧美日韩精品久久免费| 亚洲国产精品一区二区久久| 久久婷婷成人综合色综合| 国内精品久久国产| 一本久久a久久精品综合香蕉| 国产高潮国产高潮久久久91| 精品久久久久久| 国产精品久久久久久福利69堂| 亚洲国产精品无码久久SM| 一本久久综合亚洲鲁鲁五月天| 亚洲另类欧美综合久久图片区| 国产三级观看久久| 久久久WWW成人| 日本亚洲色大成网站WWW久久| 日本高清无卡码一区二区久久|