diff options
author | Nick Kralevich <nnk@google.com> | 2019-01-25 18:10:33 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-01-25 18:10:33 -0800 |
commit | 831cf61d80c00ed18ceb8e94d4d3f6244f8bbdfb (patch) | |
tree | c339c3cf6a91ad5e1f29f79c4c1c8c16152f0b6d /core/jni/fd_utils.cpp | |
parent | 97bd994bb02a52de40725c09c14f62f6ed1bfaeb (diff) | |
parent | 8d26cdbd34ba2b8d58026a9f359b14a2032dce71 (diff) |
Merge "more O_CLOEXEC" am: 350f48328b am: 51aec2267c
am: 8d26cdbd34
Change-Id: I2624180a9284beced0677de070b600c21fa24ae6
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 4e486630adae..4b37f13cbb33 100644 --- a/core/jni/fd_utils.cpp +++ b/core/jni/fd_utils.cpp @@ -423,13 +423,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))); } |