Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba43dba3 authored by Nick Kralevich's avatar Nick Kralevich Committed by android-build-merger
Browse files

Merge "fd_utils: carry over O_CLOEXEC on duplicated FDs" am: a4d036e9 am: ac9d96a0

am: bb67b501

Change-Id: I72708593cf1038a5723ab5492d7087a6936c02e6
parents 4e172cc5 bb67b501
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -331,11 +331,13 @@ bool FileDescriptorInfo::ReopenOrDetach(std::string* error_msg) const {
    return false;
  }

  if (TEMP_FAILURE_RETRY(dup2(new_fd, fd)) == -1) {
  int dupFlags = (fd_flags & FD_CLOEXEC) ? O_CLOEXEC : 0;
  if (TEMP_FAILURE_RETRY(dup3(new_fd, fd, dupFlags)) == -1) {
    close(new_fd);
    *error_msg = android::base::StringPrintf("Failed dup2(%d, %d) (%s): %s",
    *error_msg = android::base::StringPrintf("Failed dup3(%d, %d, %d) (%s): %s",
                                             fd,
                                             new_fd,
                                             dupFlags,
                                             file_path.c_str(),
                                             strerror(errno));
    return false;