summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorKoushik K. Dutta <koushd@gmail.com>2010-02-22 23:22:36 -0800
committerSteve Kondik <steve@cyngn.com>2015-10-17 17:47:21 -0700
commit5eda792697e07cb541d1f4a960fb37a160048572 (patch)
tree3722708dc27e02dd5670d02aee42ed76a9e19767 /adb
parentda40dde17b90d1867edf362d6c32c3b57567f0ec (diff)
downloadsystem_core-5eda792697e07cb541d1f4a960fb37a160048572.zip
system_core-5eda792697e07cb541d1f4a960fb37a160048572.tar.gz
system_core-5eda792697e07cb541d1f4a960fb37a160048572.tar.bz2
fix up adb to prefer /sbin/sh if it exists
Change-Id: I5c15731c95d123488e90aaeac5b497f556b53363
Diffstat (limited to 'adb')
-rw-r--r--adb/services.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/adb/services.cpp b/adb/services.cpp
index abc7695..9a3164a 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -355,8 +355,10 @@ static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg
#if ADB_HOST
#define SHELL_COMMAND "/bin/sh"
+#define ALTERNATE_SHELL_COMMAND ""
#else
#define SHELL_COMMAND "/system/bin/sh"
+#define ALTERNATE_SHELL_COMMAND "/sbin/sh"
#endif
#if !ADB_HOST
@@ -397,6 +399,9 @@ static int create_subproc_thread(const char *name, const subproc_mode mode)
int ret_fd;
pid_t pid = -1;
+ const char* shell_command;
+ struct stat st;
+
const char *arg0, *arg1;
if (name == 0 || *name == 0) {
arg0 = "-"; arg1 = 0;
@@ -404,12 +409,19 @@ static int create_subproc_thread(const char *name, const subproc_mode mode)
arg0 = "-c"; arg1 = name;
}
+ if (stat(ALTERNATE_SHELL_COMMAND, &st) == 0) {
+ shell_command = ALTERNATE_SHELL_COMMAND;
+ }
+ else {
+ shell_command = SHELL_COMMAND;
+ }
+
switch (mode) {
case SUBPROC_PTY:
- ret_fd = create_subproc_pty(SHELL_COMMAND, arg0, arg1, &pid);
+ ret_fd = create_subproc_pty(shell_command, arg0, arg1, &pid);
break;
case SUBPROC_RAW:
- ret_fd = create_subproc_raw(SHELL_COMMAND, arg0, arg1, &pid);
+ ret_fd = create_subproc_raw(shell_command, arg0, arg1, &pid);
break;
default:
fprintf(stderr, "invalid subproc_mode %d\n", mode);