Commit 4197d896 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

update readFile() to open files with O_CLOEXEC

Summary:
Files opened by `readFile()` should not be propagated to children processes
if another thread happens to spawn a subprocess while `readFile()` is running.

Reviewed By: yfeldblum, meyering

Differential Revision: D9553354

fbshipit-source-id: 2a6028b3a920bb1e76cd0b07f82e6af57d01c2a4
parent 397498c3
...@@ -172,7 +172,7 @@ bool readFile( ...@@ -172,7 +172,7 @@ bool readFile(
size_t num_bytes = std::numeric_limits<size_t>::max()) { size_t num_bytes = std::numeric_limits<size_t>::max()) {
DCHECK(file_name); DCHECK(file_name);
const auto fd = openNoInt(file_name, O_RDONLY); const auto fd = openNoInt(file_name, O_RDONLY | O_CLOEXEC);
if (fd == -1) { if (fd == -1) {
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment