title: Why does stdout not flush when connecting to a process that is run with supervisord?
body: <p>I am using Supervisor (process controller written in python) to start and control my web server and associated services.  I find the need at times to enter into pdb (or really ipdb) to debug when the server is running.  I am having trouble doing this through Supervisor.</p>
  
  <p>Supervisor allows the processes to be started and controlled with a daemon called supervisord, and offers access through a client called supervisorctl.  This client allows you to attach to one of the foreground processes that has been started using a 'fg' command.  Like this:</p>
  
  <pre><code>supervisor&gt; fg webserver
  </code></pre>
  
  <p>All logging data gets sent to the terminal.  But I do not get any text from the pdb debugger.  It does accept my input so stdin seems to be working.</p>
  
  <p>As part of my investigation I was able to confirm that neither <code>print</code> nor <code>raw_input</code> send and text out either; but in the case of <code>raw_input</code> the stdin is indeed working.</p>
  
  <p>I was also able to confirm that this works:</p>
  
  <pre><code>sys.stdout.write('message')
  sys.flush()
  </code></pre>
  
  <p>I though that when I issued the <code>fg</code> command that it would be as if I had run the process in the foreground in the standard terminal ... but it appears that supervisorctl is doing something more.  Regular printing does not flush for example. Any ideas?</p>
  
  <p><strong>How can I get pdb, standard prints, etc to work properly when connecting to the foreground terminal using the <code>fg</code> command in supervisorctl?</strong></p>
  
  <p>(Possible helpful ref: <a href="http://supervisord.org/subprocess.html#nondaemonizing-of-subprocesses" rel="nofollow">http://supervisord.org/subprocess.html#nondaemonizing-of-subprocesses</a>)</p>