diff options
author | Nick Kralevich <nnk@google.com> | 2019-01-25 18:02:23 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-01-25 18:02:23 -0800 |
commit | 8d26cdbd34ba2b8d58026a9f359b14a2032dce71 (patch) | |
tree | bffdaeb97c545679087d7ebd95f59d8a8245b8b2 /core/jni/fd_utils.cpp | |
parent | 8da21b7b21b14337dd9a1458760d617b044f89fb (diff) | |
parent | 51aec2267cb97ef68978e37d0f0d2a89cb858ad4 (diff) |
Merge "more O_CLOEXEC" am: 350f48328b
am: 51aec2267c
Change-Id: I36d95d214a9b07c474b8a8c5fdb6dbf15c4cf535
Diffstat (limited to 'core/jni/fd_utils.cpp')
-rw-r--r-- | core/jni/fd_utils.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/jni/fd_utils.cpp b/core/jni/fd_utils.cpp index 2aaf2f0a2bbe..8e6db0b74dec 100644 --- a/core/jni/fd_utils.cpp +++ b/core/jni/fd_utils.cpp @@ -418,13 +418,13 @@ bool FileDescriptorInfo::GetSocketName(const int fd, std::string* result) { } void FileDescriptorInfo::DetachSocket(fail_fn_t fail_fn) const { - const int dev_null_fd = open("/dev/null", O_RDWR); + const int dev_null_fd = open("/dev/null", O_RDWR | O_CLOEXEC); if (dev_null_fd < 0) { fail_fn(std::string("Failed to open /dev/null: ").append(strerror(errno))); } - if (dup2(dev_null_fd, fd) == -1) { - fail_fn(android::base::StringPrintf("Failed dup2 on socket descriptor %d: %s", + if (dup3(dev_null_fd, fd, O_CLOEXEC) == -1) { + fail_fn(android::base::StringPrintf("Failed dup3 on socket descriptor %d: %s", fd, strerror(errno))); } |