title: How to call an interactive D process from Mathematica?
body: <p>I'm trying to establish an interactive session with another process using Mathematicas' StartProcess. It is basically the same scenario as in <a href="http://mathematica.stackexchange.com/questions/73612">this question</a>, only that I'm calling a D program instead of a Fortran one.</p>
  
  <p>Take for instance a minimal D program that reads from Standard Input and writes to Standard Output interactively (notice the infinite loop):</p>
  
  <pre><code>// D
  void main(string[] argv) {
      while(true) {
          auto name = readln().chomp;
          writefln("Hello %s!", name);
      }
  }
  </code></pre>
  
  <p>When I run this program from the command prompt, it behaves as expected. If I would want to run it from Mathematica, this is supposed to work:</p>
  
  <pre><code>(* Mathematica *)
  dhello = StartProcess["dhello.exe"];
  WriteLine[dhello, "Wulfrick"]; 
  ReadLine[dhello]
  </code></pre>
  
  <p>but it doesn't. The call to ReadLine[] blocks, as if waiting for the Process to finish. I initially thought it may be a problem in Mathematica, but I tried calling a C# program instead and it worked! Take for instance:</p>
  
  <pre><code>// C#
  static void Main(string[] args) {
      while (true) {
          var name = Console.ReadLine();
          Console.WriteLine($"Hello {name}!");
      }
  }
  </code></pre>
  
  <p>Now on the Mathematica side, doing:</p>
  
  <pre><code>(* Mathematica *)
  cshello = StartProcess["cshello.exe"];
  WriteLine[cshello, "Wulfrick"]; 
  ReadLine[cshello]
  </code></pre>
  
  <p>Works as expected, printing the output as soon as I call ReadLine[] and maintaining interactivity. So it looks like the problem is in the D side really. Also that's why I decided to post here and not on mathematica.stackexchange.</p>
  
  <p>I would really like to make this work with the D program. Any input is much appreciated.</p>
  
  <p>System:</p>
  
  <ul>
  <li>Windows 10 x64 </li>
  <li>Mathematica 11.2 </li>
  <li>DMD v2.078.2</li>
  </ul>