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

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

Change-Id: I4731e4838e1306baff0cf03852edacffdcb1c223
parents 393e1ba2 a4d036e9
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;