From fa64cc2ac06c4b93bd50a4cc7911dbee39360441 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Mon, 22 Jan 2024 14:42:37 -0800 Subject: Fix return code of `adb shell` when device disconnects Bug: https://issuetracker.google.com/issues/321787891 Test: (adb shell sleep 60 && echo this should not echo) & sleep 1; adb tcpip 5555 Change-Id: I25f740bd222263fcb3c501def38977db6af1e0d9 --- client/commandline.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/commandline.cpp b/client/commandline.cpp index 781c6d5a..c918950d 100644 --- a/client/commandline.cpp +++ b/client/commandline.cpp @@ -288,7 +288,8 @@ static void stdin_raw_restore() { #endif int read_and_dump_protocol(borrowed_fd fd, StandardStreamsCallbackInterface* callback) { - int exit_code = 0; + // OpenSSH returns 255 on unexpected disconnection. + int exit_code = 255; std::unique_ptr protocol = std::make_unique(fd); if (!protocol) { LOG(ERROR) << "failed to allocate memory for ShellProtocol object"; -- cgit v1.2.3