diff options
author | Josh Gao <jmgao@google.com> | 2016-03-04 17:50:10 -0800 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2016-03-04 18:08:18 -0800 |
commit | fcb063ce378419ad1511d3395d44701b4ebaceb0 (patch) | |
tree | 2a95f8a6a6c19f515e86c36c02c5f921a5a9a217 /adb/shell_service.cpp | |
parent | afa76a302803fb9f25478c177486c218d713bc19 (diff) | |
download | system_core-fcb063ce378419ad1511d3395d44701b4ebaceb0.tar.gz system_core-fcb063ce378419ad1511d3395d44701b4ebaceb0.tar.bz2 system_core-fcb063ce378419ad1511d3395d44701b4ebaceb0.zip |
adbd: fix spurious close of uninitialized fd.
forkpty only returns an fd on the master side; trying to keep track of
it on both sides is incorrect.
Bug: http://b/27504427
Change-Id: Ia4a454d8490c77738f9c3350a4236b3d99c8758b
Diffstat (limited to 'adb/shell_service.cpp')
-rw-r--r-- | adb/shell_service.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp index f84447f5f..8ece28c03 100644 --- a/adb/shell_service.cpp +++ b/adb/shell_service.cpp @@ -315,7 +315,9 @@ bool Subprocess::ForkAndExec(std::string* error) { if (type_ == SubprocessType::kPty) { int fd; pid_ = forkpty(&fd, pts_name, nullptr, nullptr); - stdinout_sfd_.Reset(fd); + if (pid_ > 0) { + stdinout_sfd_.Reset(fd); + } } else { if (!CreateSocketpair(&stdinout_sfd_, &child_stdinout_sfd)) { *error = android::base::StringPrintf("failed to create socketpair for stdin/out: %s", |