Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5028e46 authored by Josh Gao's avatar Josh Gao
Browse files

adbd: use pty to determine whether a session is interactive.

Bug: http://b/26236990
Change-Id: I8baa4009a2fbe9a4c93f6ef5350ce61161b7237d
parent 17bcba16
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -183,7 +183,6 @@ class Subprocess {
    ~Subprocess();

    const std::string& command() const { return command_; }
    bool is_interactive() const { return command_.empty(); }

    int local_socket_fd() const { return local_socket_sfd_.fd(); }

@@ -332,7 +331,7 @@ bool Subprocess::ForkAndExec() {
        parent_error_sfd.Reset();
        close_on_exec(child_error_sfd.fd());

        if (is_interactive()) {
        if (command_.empty()) {
            execle(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr, cenv.data());
        } else {
            execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data());
@@ -409,20 +408,6 @@ int Subprocess::OpenPtyChildFd(const char* pts_name, ScopedFd* error_sfd) {
        exit(-1);
    }

    if (!is_interactive()) {
        termios tattr;
        if (tcgetattr(child_fd, &tattr) == -1) {
            WriteFdExactly(error_sfd->fd(), "tcgetattr failed");
            exit(-1);
        }

        cfmakeraw(&tattr);
        if (tcsetattr(child_fd, TCSADRAIN, &tattr) == -1) {
            WriteFdExactly(error_sfd->fd(), "tcsetattr failed");
            exit(-1);
        }
    }

    return child_fd;
}