The simple answer I can come up with is to have Python use Popen
to launch a shell script similar to:
gnome-terminal --window -e 'ant -Dport=5555 -Dhost=$IP1 -DhubURL=http://192.168.1.113:4444 -Denvironment=*firefox launch-remote-control $HOME/selenium-grid-1.0.8' &
disown
gnome-terminal --window -e 'ant -Dport=5555 -Dhost=$IP2 -DhubURL=http://192.168.1.113:4444 -Denvironment=*firefox launch-remote-control $HOME/selenium-grid-1.0.8' &
disown
# etc. ...
There's a fully-Python way to do this, but it's ugly, only works on Unix-like OSes, and I don't have time to write the code out. Basically, subprocess.Popen
doesn't support it because it assumes you want to either wait for the subprocess to finish, interact with the subprocess, or monitor the subprocess. It doesn't support the "just launch it and don't bother me with it ever again" case.
The way that's done in Unix-like OSes is to:
- Use
fork
to spawn a subprocess
- Have that subprocess
fork
a subprocess of its own
- Have the grandchild process redirect I/O to
/dev/null
and then use one of the exec
functions to launch the process you really want to start (might be able to use Popen
for this part)
- The child process exits.
- Now there's no link between the grandparent and grandchild, so if the grandchild terminates you don't get a
SIGCHLD
signal, and if the grandparent terminates it doesn't kill all the grandchildren.
I might be off in the details, but that's the gist. Backgrounding (&
) and disown
ing in bash
are supposed to accomplish the same thing.