'Fork and then exec sub-process.
@param path: the path where to run the new process.
@type path: L{bytes} or L{unicode}
@param uid: if defined, the uid used to run the new process.
@type uid: L{int}
@param gid: if defined, the gid used to run the new process.
@type gid: L{int}
@param executable: the executable to run in a new process.
@type executable: L{str}
@param args: arguments used to create the new process.
@type args: L{list}.
@param environment: environment used for the new process.
@type environment: L{dict}.
@param kwargs: keyword arguments to L{_setupChild} method.'

def _fork(self, path, uid, gid, executable, args, environment, **kwargs):

    collectorEnabled = gc.isenabled()
    gc.disable()
    try:
        self.pid = os.fork()
    except:
        if collectorEnabled:
            gc.enable()
        raise
    else:
        if (self.pid == 0):
            try:
                sys.settrace(None)
                self._setupChild(**kwargs)
                self._execChild(path, uid, gid, executable, args, environment)
            except:
                try:
                    stderr = os.fdopen(2, 'wb')
                    msg = 'Upon    execvpe    {0}    {1}    in    environment    id    {2}\n:'.format(executable, str(args), id(environment))
                    if _PY3:
                        stderr = io.TextIOWrapper(stderr, encoding='utf-8')
                    stderr.write(msg)
                    traceback.print_exc(file=stderr)
                    stderr.flush()
                    for fd in range(3):
                        os.close(fd)
                except:
                    pass
            os._exit(1)
    if collectorEnabled:
        gc.enable()
    self.status = (-1)
