擅长:python、mysql、java
<pre><code>import os
print 'Press enter to launch'
raw_input()
if os.fork():
# Parent
print 'clean up'
raw_input()
else:
# Child
os.execl('/usr/bin/firefox', 'firefox')
</code></pre>
<p><a href="http://docs.python.org/library/os.html#os.execl" rel="nofollow">os.execl</a>用firefox进程替换python进程。在</p>
<p>正如你所说子流程.Popen,当脚本结束时,firefox子进程被终止。在</p>
<p>使用<code>os.execl</code>,脚本本身不会结束。它被firefox进程取代,而firefox进程不会(立即)结束(也不会被终止)。一旦到达<code>os.execl</code>命令,它的行为就像您调用了<code>term -e firefox</code>一样有效。在</p>