summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan K. Taylor <dktapps@pmmp.io>2021-10-09 16:21:57 +0100
committerDylan K. Taylor <dktapps@pmmp.io>2021-10-09 16:22:08 +0100
commit68d14a723a23eac5e53d4643890f27651eb2df28 (patch)
tree8eb56bcd492882d02b3eaadeff0e50c554ab38a4
parent1454924aacba2ea3cdf183bbed512566a600b05a (diff)
downloadleveldb-68d14a723a23eac5e53d4643890f27651eb2df28.tar.gz
Prevent handle used for LOG from being inherited by subprocesses
I recently encountered a problem with this because Windows doesn't allow files to be deleted when there's open handles to them. Other files opened by leveldb are not affected because by and large they are using CreateFileA, which does not allow inheritance when lpSecurityAttributes is null (ref: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea) However, fopen() _does_ allow inheritance, and it needs to be expressly disabled. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-160
-rw-r--r--util/env_windows.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/env_windows.cc b/util/env_windows.cc
index 449f564..84905df 100644
--- a/util/env_windows.cc
+++ b/util/env_windows.cc
@@ -622,7 +622,7 @@ class WindowsEnv : public Env {
}
Status NewLogger(const std::string& filename, Logger** result) override {
- std::FILE* fp = std::fopen(filename.c_str(), "w");
+ std::FILE* fp = std::fopen(filename.c_str(), "wN");
if (fp == nullptr) {
*result = nullptr;
return WindowsError(filename, ::GetLastError());