ART: Fix android-cloexec warnings

Use the DupCloexec helper wherever possible. Add O_CLOEXEC to open
and fopen calls.

Bug: 32619234
Test: WITH_TIDY=1 mmma art
Change-Id: I0afb1beea53ab8f68ab85d1762aff999903060fe
diff --git a/libartbase/base/scoped_flock.cc b/libartbase/base/scoped_flock.cc
index beee501..2f16fb2 100644
--- a/libartbase/base/scoped_flock.cc
+++ b/libartbase/base/scoped_flock.cc
@@ -22,6 +22,7 @@
 #include <android-base/logging.h>
 #include <android-base/stringprintf.h>
 
+#include "file_utils.h"
 #include "unix_file/fd_file.h"
 
 namespace art {
@@ -98,7 +99,7 @@
   // destructor. Callers should explicitly flush files they're writing to if
   // that is the desired behaviour.
   ScopedFlock locked_file(
-      new LockedFile(dup(fd), path, /* check_usage= */ false, read_only_mode));
+      new LockedFile(DupCloexec(fd), path, /* check_usage= */ false, read_only_mode));
   if (locked_file->Fd() == -1) {
     *error_msg = StringPrintf("Failed to duplicate open file '%s': %s",
                               locked_file->GetPath().c_str(), strerror(errno));