summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nick Kralevich <nnk@google.com> 2017-10-20 15:20:34 +0000
committer android-build-merger <android-build-merger@google.com> 2017-10-20 15:20:34 +0000
commitbfe996fe1556683a696a772b9b5eca0e3366d84d (patch)
treebba2d9d89904a46915b671a5585949e23b4eb566
parentf3193c6e049ddf70db1601dab17c65c5de1668b9 (diff)
parentb8ba9d02365135798d1eab799e52e41f5a613eba (diff)
Merge "more O_CLOEXEC" am: 9f8ed6500a am: 7c27266544 am: db61fce852
am: b8ba9d0236 Change-Id: Idc4c10296fd8887016326bb45764a5ab5feb07a5
-rw-r--r--core/jni/android_os_Debug.cpp2
-rw-r--r--core/jni/android_util_Process.cpp12
2 files changed, 7 insertions, 7 deletions
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index e33d6eaea4dc..d3da21b5635b 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -755,7 +755,7 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
return;
}
- int fd = open("/proc/meminfo", O_RDONLY);
+ int fd = open("/proc/meminfo", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
ALOGW("Unable to open /proc/meminfo: %s\n", strerror(errno));
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 33c8304f2547..dec6c0226baa 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -219,7 +219,7 @@ void android_os_Process_setProcessGroup(JNIEnv* env, jobject clazz, int pid, jin
strcpy(cmdline, "unknown");
sprintf(proc_path, "/proc/%d/cmdline", pid);
- fd = open(proc_path, O_RDONLY);
+ fd = open(proc_path, O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
int rc = read(fd, cmdline, sizeof(cmdline)-1);
cmdline[rc] = 0;
@@ -555,7 +555,7 @@ jboolean android_os_Process_setSwappiness(JNIEnv *env, jobject clazz,
return false;
}
- int fd = open(text, O_WRONLY);
+ int fd = open(text, O_WRONLY | O_CLOEXEC);
if (fd >= 0) {
sprintf(text, "%" PRId32, pid);
write(fd, text, strlen(text));
@@ -603,7 +603,7 @@ static int pid_compare(const void* v1, const void* v2)
static jlong getFreeMemoryImpl(const char* const sums[], const size_t sumsLen[], size_t num)
{
- int fd = open("/proc/meminfo", O_RDONLY);
+ int fd = open("/proc/meminfo", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
ALOGW("Unable to open /proc/meminfo");
@@ -716,7 +716,7 @@ void android_os_Process_readProcLines(JNIEnv* env, jobject clazz, jstring fileSt
sizesArray[i] = 0;
}
- int fd = open(file.string(), O_RDONLY);
+ int fd = open(file.string(), O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
const size_t BUFFER_SIZE = 2048;
@@ -1023,7 +1023,7 @@ jboolean android_os_Process_readProcFile(JNIEnv* env, jobject clazz,
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
return JNI_FALSE;
}
- int fd = open(file8, O_RDONLY);
+ int fd = open(file8, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
if (kDebugProc) {
@@ -1157,7 +1157,7 @@ jintArray android_os_Process_getPidsForCommands(JNIEnv* env, jobject clazz,
char data[PATH_MAX];
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
- int fd = open(path, O_RDONLY);
+ int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
continue;
}