title: fabric run fork
body: <p>I want to use Fabric.api.run to directly start an application in a remote box. Since the application takes really a long to finish, I wish to be able to fork a child process, such that I don't need to wait for a long time.</p>
  
  <p>The code is like:</p>
  
  <pre><code>from fabric.api import run
  ....
  
  run("python ./myApp.py --fork=True &gt;myApp.log 2&gt;&amp;1")
  </code></pre>
  
  <p>I used the following code to enable forking side the code:</p>
  
  <pre><code>if settings.fork:
      child_pid = os.fork()
      if child_pid == 0:
          print "Starting Child Process: PID# %s" % os.getpid()
      else:
          print "Terminating Parent Process: PID# %s" % os.getpid()
          os._exit(0)
  </code></pre>
  
  <p>The problem is after I do the run command, I sshed into the remote box, and found out the program has been quit for some unknown reason, I check the log file, there is nothing there. </p>
  
  <p>Somebody could let me know how I can work this around? Many thanks!!</p>