adb: set O_CLOEXEC on lots of file descriptors
Too many leaking FDs.
Fixes bug: https://code.google.com/p/android/issues/detail?id=65857
(and more)
(cherrypicked from commit 777523e22a99fa05ef979aac03cfada065d9b4b0)
Change-Id: I67d8683244e54288a8105f6f65ee40abe2378d7e
diff --git a/remount_service.c b/remount_service.c
index d3a649b..3a4535e 100644
--- a/remount_service.c
+++ b/remount_service.c
@@ -39,7 +39,7 @@
const char delims[] = "\n";
char buf[4096];
- fd = unix_open("/proc/mounts", O_RDONLY);
+ fd = unix_open("/proc/mounts", O_RDONLY | O_CLOEXEC);
if (fd < 0)
return NULL;
@@ -83,7 +83,7 @@
if (!dev)
return -1;
- fd = unix_open(dev, O_RDONLY);
+ fd = unix_open(dev, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -1;