Create and detach a child process
Use the following code to create and subsequently detach a child process DETACHED_PROCESS = 0x00000008
pid = subprocess.Popen([sys.executable, "longtask.py"],
creationflags=DETACHED_PROCESS)
pid.poll() # Returns: None if child still active
# returncode otherwise
In Sym, a complex component will be made up of a parent process and related child processes.
See Also
- http://stackoverflow.com/questions/89228/calling-an-external-command-in-python
- http://docs.python.org/2/library/subprocess.html#module-subprocess
- http://stackoverflow.com/questions/13243807/popen-waiting-for-child-process-even-when-the-immediate-child-has-terminated
- http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
This only works on the Windows operating system.
ReplyDelete