Skip to content

Instantly share code, notes, and snippets.

@sleekweasel

sleekweasel/adb.cpp

Last active Feb 13, 2020
Embed
What would you like to do?
Patch for adb - prevent automatic server launch, if adb server is not running.
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 6b30be884..e05b707ed 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -664,7 +664,13 @@ static void ReportServerStartupFailure(pid_t pid) {
while (static_cast<size_t>(i) < lines.size()) fprintf(stderr, "%s\n", lines[i++].c_str());
}
+const char* env_adb_server_autostart = "ADB_SERVER_AUTOSTART";
int launch_server(const std::string& socket_spec) {
+ const char* autostart_server = getenv(env_adb_server_autostart);
+ if (autostart_server && strcmp(autostart_server, "false") == 0) {
+ fprintf(stderr, "adb: Not launching server: %s = %s\n", env_adb_server_autostart, autostart_server);
+ return -1;
+ }
#if defined(_WIN32)
/* we need to start the server in the background */
/* we create a PIPE that will be used to wait for the server's "OK" */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment