How to fork a python script in different terminal
<p>I want to fork a new process in a script, but how to interactive with the subprocess in a new terminal?
For example:</p>

<pre><code>#python
a='a'
b='b'
if os.fork():
    print a
    a = input('a?')
    print 'a:',a
else:
    print b
    b = input('b?')
    print 'b:',b
</code></pre>

<p>The script should print a/b and ask for a new value. But these two process share a same terminal, and that makes it confused.</p>

<p>How can I open a new terminal and let the subprocess run in the new terminal?</p>

<hr>

<p>I've thought about to use <code>subprocess.Popen('gnome-terminal',shell=True)</code> and communicate with the new terminal. But <code>gnome-terminal</code> will open bash on default, how can i open a terminal only for input and output?</p>

<p>Its probably bad practice to open a new terminal like that from a command line application, but <code>gnome-terminal</code> has an <code>-e</code> flag. E.g. <code>gnome-terminal -e python</code> will open a python interpreter.</p>

python linux bash shell subprocess