util: close keys file lock on exec

release-v0.5.0
moneromooo-monero 6 years ago
parent 5c85da5a73
commit a69fc05a0c
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -233,7 +233,7 @@ namespace tools
MERROR("Failed to open " << filename << ": " << std::error_code(GetLastError(), std::system_category())); MERROR("Failed to open " << filename << ": " << std::error_code(GetLastError(), std::system_category()));
} }
#else #else
m_fd = open(filename.c_str(), O_RDONLY | O_CREAT, 0666); m_fd = open(filename.c_str(), O_RDONLY | O_CREAT | O_CLOEXEC, 0666);
if (m_fd != -1) if (m_fd != -1)
{ {
if (flock(m_fd, LOCK_EX | LOCK_NB) == -1) if (flock(m_fd, LOCK_EX | LOCK_NB) == -1)

Loading…
Cancel
Save