title: How to detach Python child process on Windows (without setsid)?
body: <p>I'm migrating some process code to Windows which worked well on Posix. Very simply put: the code to launch a subprocess and immediately detach will not work because <code>setsid()</code> is not available:</p>
  
  <pre><code>import os, subprocess, sys
  p = subprocess.Popen([sys.executable, '-c', "print 'hello'"], preexec_fn=os.setsid)
  </code></pre>
  
  <p>I can remove the use of <code>setsid</code> but then the child process ends when the parent ends.</p>
  
  <p>My question is <strong>how do I achieve the same effect as <code>setsid</code> on Windows so that the child process lifetime is independent of the parent's?</strong></p>
  
  <p>I'd be willing to use a particular Python package if one exists for this sort of thing. I'm already using <code>psutil</code> for example but I didn't see anything in it that could help me.</p>