TetherController.cpp: add O_CLOEXEC
Don't leak open file descriptors across execs to netd's children. This
can occur in the unlikely but theoretically possible event that one
thread is in writeToFile() and another thread happens to call exec().
Test: device boots with no obvious problems.
Change-Id: Iabd8eee46bf94d70894ca46e58484ccb8241513a
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 6617c6a..7bf4a92 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -46,7 +46,7 @@
const char SEPARATOR[] = "|";
bool writeToFile(const char* filename, const char* value) {
- int fd = open(filename, O_WRONLY);
+ int fd = open(filename, O_WRONLY | O_CLOEXEC);
if (fd < 0) {
ALOGE("Failed to open %s: %s", filename, strerror(errno));
return false;