Use 'N' mode in fopen() to disable handle inheritance on Windows
Fixes #623
@cmumford Hi! Could you take a look?
Hi @k15tfu
Thx for the PR (with tests). Even though the docs state that only one process can access a leveldb, I'm fine with adding a protection to help protect against accidental multi-process use. One problem is that this relies on a POSIX extension that is only available on Windows - please correct me if I'm wrong. I'm worried that this would wind up with application bugs that only show up on non-Windows platforms.
@cmumford Hi! This is not for protection. Without this change, the log file handle leaks to child processes and therefore I cannot close DB and move/delete it until all handles are closed. So in my case it fails until the child process exits.
In this PR I change only Windows specific files and use platform-dependent N mode for fopen() (https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-140). A similar change was already done for fopen() in env_posix.cc (https://github.com/google/leveldb/pull/624/files#diff-6e3e34528a780e660b519271c86d81c55519dcaf2fb7965fd0b232ae5cdcf0c5L677-R688), so now there should be no difference.
@pwnall Friendly ping.
@pwnall Friendly ping.
@pwnall Friendly ping.
@pwnall @cmumford Friendly ping.
@pwnall @cmumford Friendly ping.
Just an FYI, I know this is stale, but a similar change was merged a while ago: https://github.com/google/leveldb/pull/941
Yup that's correct. Too sad that the corresponding test changes are still in this (stale) PR :(