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

This commit is contained in:
Josh Gao 2016-01-20 20:44:40 +00:00 committed by Gerrit Code Review
commit fb494eb40d
2 changed files with 4 additions and 2 deletions

View file

@ -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;
}

View file

@ -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;