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
diff --git a/client/commandline.cpp b/client/commandline.cpp
index 781c6d5..c918950 100644
--- a/client/commandline.cpp
+++ b/client/commandline.cpp
@@ -288,7 +288,8 @@
#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<ShellProtocol> protocol = std::make_unique<ShellProtocol>(fd);
if (!protocol) {
LOG(ERROR) << "failed to allocate memory for ShellProtocol object";