detached process

Robert Olson olson at mcs.anl.gov
Thu Apr 24 14:58:33 CDT 2003


(since I'm working in teh branch now)

Using this in Utilities for the app starting:

def StartDetachedProcess(cmd):
     """
     Start cmd as a detached process.

     We start the process using a command processor (cmd on windows,
     sh on linux).
     """

     if sys.platform == "win32":
         shell = os.environ['ComSpec']
         shcmd = [shell, "/c", cmd]
         os.spawnv(os.P_NOWAIT, shell, shcmd)
     else:
         shell = "sh"
         shcmd = [shell, "-c", cmd]
         os.spawnvp(os.P_NOWAIT, shell, shcmd)

Untested on linux for now, appears to work on win32. the call is:

                 if commands['open'][0:6] == "WX_DDE":
                     pid = wxExecute(commands['open'])
                 else:
                     StartDetachedProcess(commands['open'])




More information about the ag-dev mailing list