Python: subprocess Popen requires to be joined?
<p>i have a daemon running which gets command and executes it by:</p>

<pre><code>subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
</code></pre>

<p>I never do anything with it afterwards, no <code>wait()</code>, no <code>communicate()</code></p>

<p>is that okay to do so?<br>
or are joining of the process required?  </p>

<p>is there a similar thing to <code>threading.deamon=True</code> for <code>subprocess.Popen</code>? </p>

<p>Since you set <code>stdout=subprocess.PIPE, stderr=subprocess.PIPE</code>, and if you want to get the stdout, you can do this:</p>

<pre><code>p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in p.stdout:
    # do something here
    #...
</code></pre>

<p>As you say the <code>cmd</code> is executed as a daemon, I think daemon process should not be run in this way. Since once your python process exit with error, the daemon process would exited and your data will lost.</p>

<p>And if you run other process by subprocess.Popen(), such as mysql, linux comands etc, it is ok to do so. But you should know the process status(the return code), you should check the status of the process by call <code>poll()</code> or <code>wait()</code>. For more information, see <a href="https://docs.python.org/2.7/library/subprocess.html?highlight=subprocess.popen" rel="nofollow">docs of subproces.Popen</a>.</p>

python subprocess