summaryrefslogtreecommitdiffstats
path: root/adb/sysdeps.h
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2011-02-01 18:57:41 -0800
committerBenoit Goby <benoit@android.com>2011-02-02 14:14:09 -0800
commit95ef82866c7a922bf588027aa38c58a45eb84d9c (patch)
treeaa5438b9396c4a57644d316be73542585f84a59a /adb/sysdeps.h
parent305b4b0f6069d733d3023a57fdc8a6d9cf7de2a6 (diff)
downloadsystem_core-95ef82866c7a922bf588027aa38c58a45eb84d9c.zip
system_core-95ef82866c7a922bf588027aa38c58a45eb84d9c.tar.gz
system_core-95ef82866c7a922bf588027aa38c58a45eb84d9c.tar.bz2
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
Diffstat (limited to 'adb/sysdeps.h')
-rw-r--r--adb/sysdeps.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 6372649..74f4ed1 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -387,7 +387,13 @@ static __inline__ int adb_creat(const char* path, int mode)
static __inline__ int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen)
{
- return accept( serverfd, addr, addrlen );
+ int fd;
+
+ fd = accept(serverfd, addr, addrlen);
+ if (fd >= 0)
+ close_on_exec(fd);
+
+ return fd;
}
#undef accept