'Create a new child process.'

def __init__(self, reactor, protocol, command, args, environment, path):

    _pollingfile._PollingTimer.__init__(self, reactor)
    BaseProcess.__init__(self, protocol)
    sAttrs = win32security.SECURITY_ATTRIBUTES()
    sAttrs.bInheritHandle = 1
    (self.hStdoutR, hStdoutW) = win32pipe.CreatePipe(sAttrs, 0)
    (self.hStderrR, hStderrW) = win32pipe.CreatePipe(sAttrs, 0)
    (hStdinR, self.hStdinW) = win32pipe.CreatePipe(sAttrs, 0)
    win32pipe.SetNamedPipeHandleState(self.hStdinW, win32pipe.PIPE_NOWAIT, None, None)
    StartupInfo = win32process.STARTUPINFO()
    StartupInfo.hStdOutput = hStdoutW
    StartupInfo.hStdError = hStderrW
    StartupInfo.hStdInput = hStdinR
    StartupInfo.dwFlags = win32process.STARTF_USESTDHANDLES
    currentPid = win32api.GetCurrentProcess()
    tmp = win32api.DuplicateHandle(currentPid, self.hStdoutR, currentPid, 0, 0, win32con.DUPLICATE_SAME_ACCESS)
    win32file.CloseHandle(self.hStdoutR)
    self.hStdoutR = tmp
    tmp = win32api.DuplicateHandle(currentPid, self.hStderrR, currentPid, 0, 0, win32con.DUPLICATE_SAME_ACCESS)
    win32file.CloseHandle(self.hStderrR)
    self.hStderrR = tmp
    tmp = win32api.DuplicateHandle(currentPid, self.hStdinW, currentPid, 0, 0, win32con.DUPLICATE_SAME_ACCESS)
    win32file.CloseHandle(self.hStdinW)
    self.hStdinW = tmp
    env = os.environ.copy()
    env.update((environment or {}))
    newenv = {}
    for (key, value) in items(env):
        key = _fsdecode(key)
        value = _fsdecode(value)
        newenv[key] = value
    env = newenv
    args = [_fsdecode(x) for x in args]
    cmdline = quoteArguments(args)
    command = (_fsdecode(command) if command else command)
    path = (_fsdecode(path) if path else path)
    def doCreate():
        flags = win32con.CREATE_NO_WINDOW
        (self.hProcess, self.hThread, self.pid, dwTid) = win32process.CreateProcess(command, cmdline, None, None, 1, flags, env, path, StartupInfo)
    try:
        doCreate()
    except pywintypes.error as pwte:
        if (not _invalidWin32App(pwte)):
            raise OSError(pwte)
        else:
            sheb = _findShebang(command)
            if (sheb is None):
                raise OSError(('%r    is    neither    a    Windows    executable,    nor    a    script    with    a    shebang    line' % command))
            else:
                args = list(args)
                args.insert(0, command)
                cmdline = quoteArguments(args)
                origcmd = command
                command = sheb
                try:
                    doCreate()
                except pywintypes.error as pwte2:
                    if _invalidWin32App(pwte2):
                        raise OSError(('%r    has    an    invalid    shebang    line:    %r    is    not    a    valid    executable' % (origcmd, sheb)))
                    raise OSError(pwte2)
    win32file.CloseHandle(hStderrW)
    win32file.CloseHandle(hStdoutW)
    win32file.CloseHandle(hStdinR)
    self.stdout = _pollingfile._PollableReadPipe(self.hStdoutR, (lambda data: self.proto.childDataReceived(1, data)), self.outConnectionLost)
    self.stderr = _pollingfile._PollableReadPipe(self.hStderrR, (lambda data: self.proto.childDataReceived(2, data)), self.errConnectionLost)
    self.stdin = _pollingfile._PollableWritePipe(self.hStdinW, self.inConnectionLost)
    for pipewatcher in (self.stdout, self.stderr, self.stdin):
        self._addPollableResource(pipewatcher)
    self.proto.makeConnection(self)
    self._addPollableResource(_Reaper(self))
