title: C# - Close input stream of child process
body: <p>My C# program needs to send data to a 3rd-party program via its standard input. However, the program waits for the input stream to reach EOF before processing. Here my code:</p>
  
  <pre><code>// Starts the process.
  var process = new Process();
  process.StartInfo.CreateNoWindow = true;
  process.StartInfo.UseShellExecute = false;
  process.StartInfo.RedirectStandardInput = true;
  process.StartInfo.RedirectStandardOutput = true;
  process.StartInfo.FileName = "foo.exe";
  process.Start();
  
  // Sends data to child process.
  var input = process.StandardInput;
  input.WriteLine("eval('2 * PI')");
  input.Flush();
  input.Close();
  
  // Reads the result.
  var output = process.StandardOutput;
  var result = output.ReadLine();
  </code></pre>
  
  <p>The child program won't do anything and my C# code becomes stuck at <code>output.ReadLine()</code> call. However if I kill the C# process, then the child starts to work exactly on the data I've sent. How can I make the child encounter an EOF while I'm still alive?</p>