• <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.
            如果終端是標(biāo)準(zhǔn)輸出,它就是行緩存的,當(dāng)遇到新行符,則被刷新一次。
            如果標(biāo)準(zhǔn)輸出不是中斷,那它是全緩存的。如果緩沖區(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);"

            性做久久久久久久久久久| 国产99久久久久久免费看| 亚洲精品97久久中文字幕无码 | 久久久一本精品99久久精品88| 久久久久国产精品人妻| 潮喷大喷水系列无码久久精品| 国产精品无码久久久久| 久久天天婷婷五月俺也去| 久久久久久久亚洲Av无码| 久久成人精品| 久久国产精品一国产精品金尊| 久久久久国色AV免费观看| 久久久久久久亚洲Av无码| 久久一区二区免费播放| 99久久99久久| 亚洲va久久久噜噜噜久久男同 | 久久丫精品国产亚洲av不卡| 国产精品成人无码久久久久久 | 久久国产三级无码一区二区| 一本一本久久a久久综合精品蜜桃| 97久久精品人人澡人人爽| 少妇内射兰兰久久| 欧美伊人久久大香线蕉综合| 国产成人久久精品二区三区| 国产V亚洲V天堂无码久久久| 色播久久人人爽人人爽人人片AV| 国产—久久香蕉国产线看观看 | 久久精品国产亚洲AV高清热| 狠狠色婷婷久久一区二区| 中文字幕精品无码久久久久久3D日动漫 | 亚洲国产另类久久久精品| 亚洲午夜无码AV毛片久久| 国产激情久久久久影院老熟女免费 | 无码伊人66久久大杳蕉网站谷歌 | 色偷偷91久久综合噜噜噜噜| 色综合久久久久网| 四虎国产精品免费久久久| 久久久久国产一级毛片高清版| 久久精品一区二区| 久久久久国色AV免费看图片 | 欧美熟妇另类久久久久久不卡|