diff --git a/galera/src/saved_state.cpp b/galera/src/saved_state.cpp index 119621c6e..42b3f4aa7 100644 --- a/galera/src/saved_state.cpp +++ b/galera/src/saved_state.cpp @@ -13,6 +13,12 @@ #include #include +#ifdef __GLIBC__ +#define STR_O_EXCL_CLOEXEC "ex" +#else +#define STR_O_EXCL_CLOEXEC "" +#endif + namespace galera { @@ -44,7 +50,7 @@ SavedState::SavedState (const std::string& file) : log_warn << "Could not open state file for reading: '" << file << '\''; } - fs_ = fopen(file.c_str(), "a"); + fs_ = fopen(file.c_str(), "a" STR_O_EXCL_CLOEXEC); if (!fs_) {