summaryrefslogtreecommitdiff
path: root/profman/profman.cc
diff options
context:
space:
mode:
Diffstat (limited to 'profman/profman.cc')
-rw-r--r--profman/profman.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/profman/profman.cc b/profman/profman.cc
index d989c8c849..734cdf498e 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -477,7 +477,7 @@ class ProfMan final {
std::unique_ptr<const ProfileCompilationInfo> LoadProfile(const std::string& filename, int fd) {
if (!filename.empty()) {
- fd = open(filename.c_str(), O_RDWR);
+ fd = open(filename.c_str(), O_RDWR | O_CLOEXEC);
if (fd < 0) {
LOG(ERROR) << "Cannot open " << filename << strerror(errno);
return nullptr;
@@ -641,7 +641,7 @@ class ProfMan final {
bool GetClassNamesAndMethods(const std::string& profile_file,
std::vector<std::unique_ptr<const DexFile>>* dex_files,
std::set<std::string>* out_lines) {
- int fd = open(profile_file.c_str(), O_RDONLY);
+ int fd = open(profile_file.c_str(), O_RDONLY | O_CLOEXEC);
if (!FdIsValid(fd)) {
LOG(ERROR) << "Cannot open " << profile_file << strerror(errno);
return false;
@@ -1022,7 +1022,7 @@ class ProfMan final {
int fd = reference_profile_file_fd_;
if (!FdIsValid(fd)) {
CHECK(!reference_profile_file_.empty());
- fd = open(reference_profile_file_.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ fd = open(reference_profile_file_.c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644);
if (fd < 0) {
LOG(ERROR) << "Cannot open " << reference_profile_file_ << strerror(errno);
return kInvalidFd;
@@ -1155,7 +1155,9 @@ class ProfMan final {
}
}
// ShouldGenerateTestProfile confirms !test_profile_.empty().
- int profile_test_fd = open(test_profile_.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ int profile_test_fd = open(test_profile_.c_str(),
+ O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC,
+ 0644);
if (profile_test_fd < 0) {
LOG(ERROR) << "Cannot open " << test_profile_ << strerror(errno);
return -1;