Fix adb leaking file descriptors to forked processes
accept() creates a new file descriptor that should be closed on exec so
that forked processes don't keep a fd opened on the socket.
This also fixes b/3297070 where adb hangs after running adb on the
target.
Change-Id: I8df511289e5549ae49b4824c9dfb71a3bf85eae8
diff --git a/adb/adb.c b/adb/adb.c
index 679b086..f5e6e0c 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -682,9 +682,11 @@
dup2(fd, 1);
dup2(fd, 2);
fprintf(stderr,"--- adb starting (pid %d) ---\n", getpid());
+ adb_close(fd);
fd = unix_open("/dev/null", O_RDONLY);
dup2(fd, 0);
+ adb_close(fd);
}
#endif