title: Two programs that interact with each other at runtime
body: <p><a href="https://codegolf.meta.stackexchange.com/a/1411/12205">This question</a> on the codegolf.SE sandbox is about writing hangman solvers. I want to write a main "game" program that outputs underscores, and takes single alphabets as input; and another program, the "solver", will take the underscores as input and outputs the letters.</p>
  
  <p>I have no previous knowledge on how to do this. I tried the method described <a href="https://stackoverflow.com/q/5129276/3488231">here</a> and <a href="https://stackoverflow.com/q/40244/3488231">here</a>, but still no luck.</p>
  
  <p>My sample game program in python is as follows:</p>
  
  <pre class="lang-py prettyprint-override"><code>import sys
  s="HANGMAN"
  s2=[]
  for i in s:
      s2.append('_')
  err=0
  print ''.join(s2)
  sys.stderr.write('debug _______\n')
  while err&lt;6 and '_' in s2:
      c=raw_input()
      nomatch=True
      for i in range(0, len(s)):
          if s[i]==c:
              s2[i]=c
              nomatch=False
      if nomatch:
          err+=1
      print ''.join(s2)
  </code></pre>
  
  <p>And my sample solver program is as follows:</p>
  
  <pre class="lang-py prettyprint-override"><code>import sys
  raw_input()
  sys.stderr.write('debug H\n')
  print 'H'
  raw_input()
  print 'A'
  raw_input()
  print 'N'
  raw_input()
  print 'G'
  raw_input()
  print 'M'
  raw_input()
  </code></pre>
  
  <p>Then in my terminal I tried the following:</p>
  
  <pre><code>mkfifo fifo
  python game.py &lt;fifo | python solver.py &gt;fifo
  </code></pre>
  
  <p>And</p>
  
  <pre><code>coproc python game.py
  python solver.py &lt;&amp;${COPROC[0]} &gt;&amp;${COPROC[1]}
  </code></pre>
  
  <p>And</p>
  
  <pre><code>{ python game.py | python solver.py; } &gt;/dev/fd/0
  </code></pre>
  
  <p>All of these give only the first debug message from game.py, and then seems like both programs are waiting for input. What did I do wrong and how do I fix this?</p>