MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / Detach

Method Detach

module/src/main/cpp/external/fdutils/fd_utils.cpp:155–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155void FileDescriptorInfo::Detach(fail_fn_t fail_fn) const {
156 const int dev_null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_RDWR | O_CLOEXEC));
157 if (dev_null_fd < 0) {
158 fail_fn(android::base::StringPrintf("Failed to open /dev/null: %s", strerror(errno)));
159 return;
160 }
161
162 if (TEMP_FAILURE_RETRY(dup3(dev_null_fd, fd, O_CLOEXEC)) == -1) {
163 fail_fn(android::base::StringPrintf("Failed dup3 on descriptor %d to /dev/null: %s",
164 fd,
165 strerror(errno)));
166 // close(dev_null_fd) should still be attempted
167 }
168
169 if (TEMP_FAILURE_RETRY(close(dev_null_fd)) == -1) {
170 fail_fn(android::base::StringPrintf("Failed close(/dev/null temp fd %d): %s", dev_null_fd, strerror(errno)));
171 }
172}
173
174void FileDescriptorInfo::ReopenOrDetach(fail_fn_t fail_fn, bool prefer_detach_to_dev_null) const {
175 if (is_sock) {

Callers

nothing calls this directly

Calls 1

StringPrintfFunction · 0.85

Tested by

no test coverage detected