Merge "Use O_CLOEXEC at a few places."
am: e3857ca43e
Change-Id: If5b1622ca66d0722107bdac5daef1eda823cdf20
diff --git a/minui/events.cpp b/minui/events.cpp
index d94e977..30f8d50 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -66,7 +66,7 @@
dirent* de;
while ((de = readdir(dir))) {
if (strncmp(de->d_name, "event", 5)) continue;
- int fd = openat(dirfd(dir), de->d_name, O_RDONLY);
+ int fd = openat(dirfd(dir), de->d_name, O_RDONLY | O_CLOEXEC);
if (fd == -1) continue;
// Use unsigned long to match ioctl's parameter type.
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index 9eea497..10cd607 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -101,7 +101,7 @@
err = adf_device_attach(dev, eng_id, intf_id);
if (err < 0 && err != -EALREADY) return err;
- intf_fd = adf_interface_open(dev, intf_id, O_RDWR);
+ intf_fd = adf_interface_open(dev, intf_id, O_RDWR | O_CLOEXEC);
if (intf_fd < 0) return intf_fd;
err = InterfaceInit();
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index 765e262..7b2eed1 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -285,7 +285,7 @@
/* Consider DRM devices in order. */
for (int i = 0; i < DRM_MAX_MINOR; i++) {
auto dev_name = android::base::StringPrintf(DRM_DEV_NAME, DRM_DIR_NAME, i);
- android::base::unique_fd fd(open(dev_name.c_str(), O_RDWR));
+ android::base::unique_fd fd(open(dev_name.c_str(), O_RDWR | O_CLOEXEC));
if (fd == -1) continue;
/* We need dumb buffers. */
diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp
index 8d9c974..2584017 100644
--- a/minui/graphics_fbdev.cpp
+++ b/minui/graphics_fbdev.cpp
@@ -56,7 +56,7 @@
}
GRSurface* MinuiBackendFbdev::Init() {
- android::base::unique_fd fd(open("/dev/graphics/fb0", O_RDWR));
+ android::base::unique_fd fd(open("/dev/graphics/fb0", O_RDWR | O_CLOEXEC));
if (fd == -1) {
perror("cannot open fb0");
return nullptr;