• <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);"

            亚洲国产小视频精品久久久三级| 久久er99热精品一区二区| 国产午夜精品久久久久九九| 久久精品无码一区二区日韩AV| 久久久黄色大片| 久久996热精品xxxx| 国产精品久久久天天影视| 蜜臀久久99精品久久久久久小说| 亚洲成色999久久网站| 成人午夜精品无码区久久| 亚洲Av无码国产情品久久| 国产精品欧美亚洲韩国日本久久 | 国内精品久久久久久久久电影网| 99精品国产在热久久无毒不卡| 国色天香久久久久久久小说 | 伊人久久精品影院| 久久综合视频网站| 热99RE久久精品这里都是精品免费| 久久精品国产国产精品四凭| 成人a毛片久久免费播放| 91久久精品91久久性色| 天天爽天天爽天天片a久久网| 97久久精品午夜一区二区| 精品综合久久久久久97超人| 国产精品视频久久久| 国产精品美女久久久久av爽| 亚洲精品乱码久久久久久蜜桃| 2020久久精品亚洲热综合一本| 日本欧美久久久久免费播放网| 伊人久久大香线焦综合四虎| 办公室久久精品| 久久精品水蜜桃av综合天堂| 国产精品久久久久久久人人看| 国产精品久久久久久久久鸭| 亚洲国产另类久久久精品| 久久中文字幕视频、最近更新| 久久精品国产99久久无毒不卡| 国产精品久久久久蜜芽| 国产精品美女久久福利网站| 精品久久人人做人人爽综合| 久久大香香蕉国产|