summaryrefslogtreecommitdiff
path: root/client/main.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2015-11-20 15:37:31 -0800
committerJosh Gao <jmgao@google.com>2015-12-10 12:52:06 -0800
commit09b4a3b561094d1b15c1fa2c74ffb04bdb9278b8 (patch)
tree6775770fff996f57215070b4cf8dbe18094b364a /client/main.cpp
parente821a5d6eaf21382c4fdd70cf6fc88cf82798939 (diff)
downloadadb-09b4a3b561094d1b15c1fa2c74ffb04bdb9278b8.tar.gz
adb: shell: add -n flag to not read from stdin.
Shell scripts of the following form do not work properly with adb: echo "foo\nbar\nbaz" | { read FOO while [ "$FOO" != "" ]; do adb shell echo $FOO read FOO done } The first run of adb shell will consume all of the contents of stdin, causing the loop to immediately end. ssh solves this by providing a -n flag that causes it to not read from stdin. This commit adds the same. Bug: http://b/25817224 Change-Id: Id74ca62ef520bcf03678b50f4bf203916fd81038
Diffstat (limited to 'client/main.cpp')
-rw-r--r--client/main.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/client/main.cpp b/client/main.cpp
index 04b9882..1ac6e82 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -34,11 +34,10 @@
#include "adb.h"
#include "adb_auth.h"
#include "adb_listeners.h"
+#include "adb_utils.h"
#include "transport.h"
#if defined(_WIN32)
-static const char kNullFileName[] = "NUL";
-
static BOOL WINAPI ctrlc_handler(DWORD type) {
// TODO: Consider trying to kill a starting up adb server (if we're in
// launch_server) by calling GenerateConsoleCtrlEvent().
@@ -66,24 +65,11 @@ static std::string GetLogFilePath() {
return temp_path_utf8 + log_name;
}
#else
-static const char kNullFileName[] = "/dev/null";
-
static std::string GetLogFilePath() {
return std::string("/tmp/adb.log");
}
#endif
-static void close_stdin() {
- int fd = unix_open(kNullFileName, O_RDONLY);
- if (fd == -1) {
- fatal("cannot open '%s': %s", kNullFileName, strerror(errno));
- }
- if (dup2(fd, STDIN_FILENO) == -1) {
- fatal("cannot redirect stdin: %s", strerror(errno));
- }
- unix_close(fd);
-}
-
static void setup_daemon_logging(void) {
const std::string log_file_path(GetLogFilePath());
int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0640);