title: How can I prevent the parent from blocking when writing to a child?
body: <p>Recently I had a problem using (pipe |-) when I wanted to communicate between two processes. 
  Basically, the child process couldn't process STDIN as fast as it was filled up by parent. This caused parent to wait until STDIN was free and made it run slow.</p>
  
  <p>How big can STDIN be and is it possible to modify it. If yes, what is the best practice size?</p>
  
  <p>Here is some code sample to show what I mean:</p>
  
  <pre><code>if ($child_pid = open($child, "|-"))
  {
      $child-&gt;autoflush(1);
  
      # PARENT process
      while (1)
      {
  
               # Read packet from socket save in $packet
               process_packet($packet);
  
               # forward packet to child
               print $child $packet;
       }
  }
  else
  {
       die "Cannot fork: $!" unless defined $child_pid;
       # CHILD process
       my $line;  
  
       while($line = &lt;STDIN&gt;)
       {
           chomp $line;
           another_process_packet($line);
       }
  }
  </code></pre>
  
  <p>In this sample <code>another_process_packet</code> slower than <code>process_packet</code>. The reason I write the code like this is, I want to use same data comes from socket and actually get it once.</p>
  
  <p>Thanks in advance.</p>