title: Using "tee" makes the stdout slow
body: <p>I have a program which does a lot of work. I want to log all the console prints into a file. So i used a tee with my executable.</p>
  
  <p>I implemented a tee which reads from stdin and writes to stdout and a file.</p>
  
  <p><strong>exec run.sh | tee loglink</strong></p>
  
  <p>But what i could see is, time to get the login for my program, which used to be 3 mins now is taking 6 mins. </p>
  
  <p>What is the reason for this delay? I commented file operation part of my tee, still seeing the same delay. Is it the pipeline that is causing this issue?</p>
  
  <p>Adding code,</p>
  
  <pre><code>char ch;
  fd = open(file_name, O_WRONLY | O_APPEND, 0664);
  while(read(STDIN_FILENO, &amp;ch, 1) &gt; 0)
  {
      write(STDOUT_FILENO, &amp;ch, 1); //write to console
      fflush(stdout);
      write(fd, &amp;ch, 1); //write to the file
  }
  </code></pre>