summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-05 22:45:58 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-05 22:45:58 +0000
commit08d719d25e855d34703165a4e41548750f518162 (patch)
tree32291f3c85b8a018eed1ee7ed34f73b1820d03d6
parent94a86a4f97d610c63928ec6faae513ce409f9633 (diff)
parentcced7693520d6376fe25fa4698c2b5ec7d6364a0 (diff)
downloadsystem_core-08d719d25e855d34703165a4e41548750f518162.zip
system_core-08d719d25e855d34703165a4e41548750f518162.tar.gz
system_core-08d719d25e855d34703165a4e41548750f518162.tar.bz2
am cced7693: am 5605c10a: am 101c57f7: Merge "Disable CR/LF translation for adb interactive shell."
* commit 'cced7693520d6376fe25fa4698c2b5ec7d6364a0': Disable CR/LF translation for adb interactive shell.
-rw-r--r--adb/commandline.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index f9ca5ed..34efefe 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -256,29 +256,25 @@ void stdin_raw_restore(int fd);
}
#else
-static struct termios tio_save;
+static termios g_saved_terminal_state;
-static void stdin_raw_init(int fd)
-{
- struct termios tio;
+static void stdin_raw_init(int fd) {
+ if (tcgetattr(fd, &g_saved_terminal_state)) return;
- if(tcgetattr(fd, &tio)) return;
- if(tcgetattr(fd, &tio_save)) return;
+ termios tio;
+ if (tcgetattr(fd, &tio)) return;
- tio.c_lflag = 0; /* disable CANON, ECHO*, etc */
+ cfmakeraw(&tio);
- /* no timeout but request at least one character per read */
+ // No timeout but request at least one character per read.
tio.c_cc[VTIME] = 0;
tio.c_cc[VMIN] = 1;
- tcsetattr(fd, TCSANOW, &tio);
- tcflush(fd, TCIFLUSH);
+ tcsetattr(fd, TCSAFLUSH, &tio);
}
-static void stdin_raw_restore(int fd)
-{
- tcsetattr(fd, TCSANOW, &tio_save);
- tcflush(fd, TCIFLUSH);
+static void stdin_raw_restore(int fd) {
+ tcsetattr(fd, TCSAFLUSH, &g_saved_terminal_state);
}
#endif