scopedfd_helper.cc 663 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <unistd.h>
  5. #include <vector>
  6. #include "base/check.h"
  7. #include "base/posix/eintr_wrapper.h"
  8. #include "media/base/scopedfd_helper.h"
  9. namespace media {
  10. std::vector<base::ScopedFD> DuplicateFDs(
  11. const std::vector<base::ScopedFD>& fds) {
  12. std::vector<base::ScopedFD> ret;
  13. for (auto& fd : fds) {
  14. base::ScopedFD dup_fd = base::ScopedFD(HANDLE_EINTR(dup(fd.get())));
  15. PCHECK(dup_fd.is_valid());
  16. ret.push_back(std::move(dup_fd));
  17. }
  18. return ret;
  19. }
  20. } // namespace media