def hybrid_tty_create_child(args):
    """
    Like :func:`tty_create_child`, except attach stdin/stdout to a socketpair
    like :func:`create_child`, but leave stderr and the controlling TTY
    attached to a TTY.

    :param list args:
        :py:func:`os.execl` argument list.

    :returns:
        `(pid, socketpair_fd, tty_fd)`
    """
    master_fd, slave_fd = openpty()

    try:
        disable_echo(master_fd)
        disable_echo(slave_fd)
        mitogen.core.set_block(slave_fd)

        parentfp, childfp = create_socketpair()
        try:
            mitogen.core.set_block(childfp)
            pid = detach_popen(
                args=args,
                stdin=childfp,
                stdout=childfp,
                stderr=slave_fd,
                preexec_fn=_acquire_controlling_tty,
                close_fds=True,
            )
        except Exception:
            parentfp.close()
            childfp.close()
            raise
    except Exception:
        os.close(master_fd)
        os.close(slave_fd)
        raise

    os.close(slave_fd)
    childfp.close()
    # Decouple the socket from the lifetime of the Python socket object.
    stdio_fd = os.dup(parentfp.fileno())
    parentfp.close()

    LOG.debug('hybrid_tty_create_child() pid=%d stdio=%d, tty=%d, cmd: %s',
              pid, stdio_fd, master_fd, Argv(args))
    return pid, stdio_fd, master_fd
Like :func:`tty_create_child`, except attach stdin/stdout to a socketpair
    like :func:`create_child`, but leave stderr and the controlling TTY
    attached to a TTY.

    :param list args:
        :py:func:`os.execl` argument list.

    :returns:
        `(pid, socketpair_fd, tty_fd)`