title: Why my subprocess STDOUT prints nothing under nohup
body: <p>I have a code executed the following way</p>
  
  <pre><code>$ python mycode.py param1 param2 
  </code></pre>
  
  <p>It produces output using <a href="https://docs.python.org/2/library/subprocess.html" rel="nofollow">subprocess</a> inside <code>mycode.py</code>:</p>
  
  <pre><code>import subprocess
  paramlist = ['othercodes.py','infilel.txt']
  
  p = subprocess.Popen(paramlist,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  out, err = p.communicate()
  
  # out is empty under nohup
  print out
  </code></pre>
  
  <p>I have no problem getting the complete result using these commands:</p>
  
  <pre><code> $ python mycode.py  &gt; output.txt 
   $ python mycode.py   &gt;&gt; output.txt 
  </code></pre>
  
  <p>But when I do one of this,  I get empty result in <code>output.txt</code>:</p>
  
  <pre><code> $ nohup python mycode.py   &gt; output.txt &amp;
   $ nohup python mycode.py   &gt;&gt; output.txt &amp;
   $ nohup python mycode.py   &gt;&gt; output.txt 2&gt;&amp;1  
  </code></pre>
  
  <p>What's the correct way to do it?</p>
  
  <p><strong>Update</strong>: </p>
  
  <p>I fixed the problem. As pointed by CharlesDuffy the problem is in <code>othercodes.py</code>.
  In particular these lines:</p>
  
  <pre><code>        # # If there's input ready, do something, else do something
          # # else. Note timeout is zero so select won't block at all.
  
          # if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
          #     infile = sys.stdin.readline().strip()
          #     args.append(infile)
  </code></pre>
  
  <p>Once I commented out the last 3 lines, <code>mycode.py</code> then works fine.</p>