libutil/unix: Add O_CLOEXEC to openDirectory

As a precaution. This function might get used for some long persisted
file descriptor and we need good defaults.
This commit is contained in:
Sergei Zimmerman
2025-11-21 02:43:26 +03:00
parent 5caebab63a
commit ea4854fda1

View File

@@ -16,7 +16,7 @@ namespace nix {
Descriptor openDirectory(const std::filesystem::path & path)
{
return open(path.c_str(), O_RDONLY | O_DIRECTORY);
return open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
}
void setWriteTime(