title: Spawn a subprocess in foreground, even after python exits
body: <p>Assume there exists a python script resolve_ip.py which magically returns the string IP of a machine we care about.</p>
  
  <p>I'm interested in learning how to achieve the python equivalent of the following bash command:</p>
  
  <pre><code>user@host:~$ ssh $(./resolve_ip.py)
  </code></pre>
  
  <p>In this bash example, after the python script runs, it is replaced or rather substituted with its return value which is, in turn, provided as a input to the program ssh. The result is, the python program terminates and the user interacts with ssh initialization. </p>
  
  <p>The problem is, this solution requires the use of either 2 scripts (a bash script to run ssh, combined with the python script to return the arguments) or alternatively human intervention to type the bash command directly as formatted above.</p>
  
  <p>Question: </p>
  
  <p>Is there a way, only using python, to start/fork an interactive service (like ssh), by using subprocess or some comparable module, and have this forked child process remain alive in the foreground, even after its parent (python) has sys.exit()'d?</p>
  
  <p>Considerations:</p>
  
  <p>In this case, the point of this question is not to script the submission of ssh credentials to ssh from within Python. It is how to spawn a subprocess which continues to run foregrounded after its parent/spawner terminates.</p>
  
  <p>EDIT:
  The following resources are related:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6011235/run-a-program-from-python-and-have-it-continue-to-run-after-the-script-is-kille">Run a program from python, and have it continue to run after the script is killed</a>
  <a href="https://stackoverflow.com/questions/20646519/how-to-spawn-new-independent-process-in-python?rq=1">how to spawn new independent process in python</a></li>
  <li><a href="https://stackoverflow.com/questions/8425116/indefinite-daemonized-process-spawning-in-python">Indefinite daemonized process spawning in Python</a></li>
  <li><a href="https://stackoverflow.com/questions/5772873/python-spawn-off-a-child-subprocess-detach-and-exit">Python spawn off a child subprocess, detach, and exit</a></li>
  </ul>