

def spawn_independent(command, shell=False):
    " Given a command suitable for 'Popen', open the process such that if this\n        process is killed, the spawned process survives.\n\n        `command` is either a list of strings, with the first item in the list being\n        the executable and the rest being its arguments, or a single string containing\n        the executable and its arguments.  In the latter case, any argument that\n        contains spaces must be delimited with double-quotes.\n    "
    if (sys.platform == 'win32'):
        if isinstance(command, STRING_BASE_CLASS):
            command = ('start /b ' + command)
        else:
            command.insert(0, 'start')
            command.insert(1, '/b')
        Popen(command, shell=True)
    elif (sys.platform == 'darwin'):
        pid = os.fork()
        if pid:
            return
        else:
            os.setpgrp()
            if isinstance(command, STRING_BASE_CLASS):
                tmp = quoted_split(command)
            else:
                tmp = command
            os.execv(tmp[0], tmp)
    else:
        pid = os.fork()
        if pid:
            return
        else:
            os.setpgrp()
            Popen(command, shell=shell)
            sys.exit(0)

dataset/ETHPy150Open enthought/envisage/envisage/plugins/remote_editor/communication/util.py spawn_independent/original