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

Commit bb67b501 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

Change-Id: I3b5b7c38522140f928a0f779ca60a8c93ed6cf4d
parents d090104b ac9d96a0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -327,11 +327,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;