diff options
author | Howard Chu <hyc@symas.com> | 2019-11-17 11:41:09 +0000 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2019-11-17 14:04:22 +0000 |
commit | 47d094c0c40605572f2fe3a9d62cb5c96ef37de8 (patch) | |
tree | 92de5a57def7ff241e3e92ef270076d2142356d7 /src/daemonizer/posix_fork.cpp | |
parent | Merge pull request #6135 (diff) | |
download | monero-47d094c0c40605572f2fe3a9d62cb5c96ef37de8.tar.xz |
Fix #6147 DB corruption from child process overwrite
Don't leave stdout/stderr dangling on a fork.
Diffstat (limited to 'src/daemonizer/posix_fork.cpp')
-rw-r--r-- | src/daemonizer/posix_fork.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/daemonizer/posix_fork.cpp b/src/daemonizer/posix_fork.cpp index 5af4e1a4a..16758215d 100644 --- a/src/daemonizer/posix_fork.cpp +++ b/src/daemonizer/posix_fork.cpp @@ -127,13 +127,18 @@ void fork(const std::string & pidfile) { quit("Unable to open output file: " + output); } +#else + if (open("/dev/null", O_WRONLY) < 0) + { + quit("Unable to open /dev/null"); + } +#endif // Also send standard error to the same log file. if (dup(1) < 0) { quit("Unable to dup output descriptor"); } -#endif } } // namespace posix |