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

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

adbd: don't leave zombies when subprocess creation fails.

Bug: http://b/26660675
Change-Id: I8e65d51af73f409c30be47575f76bc6b0f227c54
parent d0009911
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -306,12 +306,14 @@ static void fdevent_subproc_event_func(int fd, unsigned ev,
        auto it = g_poll_node_map.find(subproc_fd);
        if (it == g_poll_node_map.end()) {
            D("subproc_fd %d cleared from fd_table", subproc_fd);
            adb_close(subproc_fd);
            return;
        }
        fdevent* subproc_fde = it->second.fde;
        if(subproc_fde->fd != subproc_fd) {
            // Already reallocated?
            D("subproc_fd(%d) != subproc_fde->fd(%d)", subproc_fd, subproc_fde->fd);
            LOG(FATAL) << "subproc_fd(" << subproc_fd << ") != subproc_fde->fd(" << subproc_fde->fd
                       << ")";
            return;
        }

+1 −1
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ Subprocess::Subprocess(const std::string& command, const char* terminal_type,
}

Subprocess::~Subprocess() {
    WaitForExit();
}

bool Subprocess::ForkAndExec() {
@@ -432,7 +433,6 @@ void* Subprocess::ThreadHandler(void* userdata) {
            "shell srvc %d", subprocess->local_socket_fd()));

    subprocess->PassDataStreams();
    subprocess->WaitForExit();

    D("deleting Subprocess for PID %d", subprocess->pid());
    delete subprocess;