'Create a child process.
"cmd" is the command to run, either a list of arguments or a string.
"cwd" is a working directory in which to start the child process.
"env" is an environment dictionary for the child.
"flags" are system-specific process creation flags. On Windows
this can be a bitwise-OR of any of the win32process.CREATE_*
constants (Note: win32process.CREATE_NEW_PROCESS_GROUP is always
OR\'d in). On Unix, this is currently ignored.
"stdin", "stdout", "stderr" can be used to specify file objects
to handle read (stdout/stderr) and write (stdin) events from/to
the child. By default a file handle will be created for each
io channel automatically, unless set explicitly to None. When set
to None, the parent io handles will be used, which can mean the
output is redirected to Komodo\'s log files.
"universal_newlines": On by default (the opposite of subprocess).'

def __init__(self, cmd, cwd=None, env=None, flags=None, stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True):

    self._child_created = False
    self.__use_killpg = False
    auto_piped_stdin = False
    preexec_fn = None
    shell = False
    if (not isinstance(cmd, (list, tuple))):
        shell = True
    if sys.platform.startswith('win'):
        if (cmd and shell and (cmd.count('"') > 2)):
            if ((not cmd.startswith('""')) or (not cmd.endswith('""'))):
                cmd = ('"%s"' % (cmd,))
        if env:
            encoding = sys.getfilesystemencoding()
            _enc_env = {}
            for (key, value) in env.items():
                try:
                    _enc_env[key.encode(encoding)] = value.encode(encoding)
                except (UnicodeEncodeError, UnicodeDecodeError):
                    log.warn('Could    not    encode    environment    variable    %r    so    removing    it', key)
            env = _enc_env
        if (flags is None):
            flags = CREATE_NO_WINDOW
        if (self._needToHackAroundStdHandles() and (not (flags & CREATE_NEW_CONSOLE))):
            if self._checkFileObjInheritable(sys.stdin, 'STD_INPUT_HANDLE'):
                stdin = PIPE
                auto_piped_stdin = True
            if self._checkFileObjInheritable(sys.stdout, 'STD_OUTPUT_HANDLE'):
                stdout = PIPE
            if self._checkFileObjInheritable(sys.stderr, 'STD_ERROR_HANDLE'):
                stderr = PIPE
    else:
        flags = 0
        preexec_fn = os.setsid
        self.__use_killpg = True
    self.__cmd = cmd
    self.__retval = None
    self.__hasTerminated = threading.Condition()
    Popen.__init__(self, cmd, cwd=cwd, env=env, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, universal_newlines=universal_newlines, creationflags=flags)
    if auto_piped_stdin:
        self.stdin.close()
