I am writing a python program that runs the following:
import subprocess
import time
def fun1():
terminal1 = ['gnome-terminal']
terminal1.extend(['-x', 'sh', '-c', '"roscore"'])
pid = subprocess.Popen(terminal1, stdout=subprocess.PIPE)
time.sleep(3)
print "success1"
fun2()
def fun2():
terminal2 = ['gnome-terminal']
terminal2.extend(['-x', 'sh', '-c', '"rosrun rosserial_python serial_node.py /dev/ttyACM0"' ])
pid2 = subprocess.Popen(terminal2, stdout=subprocess.PIPE)
print "success2"
fun1()
fun1 works properly, I wait 3 seconds because it lasts sometime until everything is done so that the fun2 can work (I can't launch both simultaneously, fun2 has to wait to fun1, which never ends before fun2)
the problem comes when running fun2, I don't know where is the mistake, is the "same" code as in fun1, but the gnome-terminal just appears for few milliseconds and then it disappears...
any suggestion??
thank you in advance