Question regarding subprocess in python
<p>I have a question regarding subprocess popen()</p>

<p>If suppose the command executed is in a while loop is there any way for the subprocess.popen to detect it and exit after printing the first output?</p>

<p>Or is there any other way to do this and print the result</p>

<p>As u see  the following program executed on a linux machine just keeps on executing</p>

<pre><code>  &gt;&gt;&gt; import os
  &gt;&gt;&gt; import subprocess as sp
  &gt;&gt;&gt; p = sp.Popen("yes", stdout=sp.PIPE)
  &gt;&gt;&gt; result = p.communicate()[0]
</code></pre>
