diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp index 25e8376a0..386f22186 100644 --- a/adb/fdevent.cpp +++ b/adb/fdevent.cpp @@ -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; } diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp index 366ed074a..95dff117e 100644 --- a/adb/shell_service.cpp +++ b/adb/shell_service.cpp @@ -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;