diff options
Diffstat (limited to 'src/mongo/util/processinfo.cpp')
-rw-r--r-- | src/mongo/util/processinfo.cpp | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/src/mongo/util/processinfo.cpp b/src/mongo/util/processinfo.cpp index 53e954d44da..5a0e8dc798c 100644 --- a/src/mongo/util/processinfo.cpp +++ b/src/mongo/util/processinfo.cpp @@ -43,47 +43,45 @@ using namespace std; namespace mongo { - class PidFileWiper { - public: - ~PidFileWiper() { - if (path.empty()) { - return; - } - - ofstream out( path.c_str() , ios_base::out ); - out.close(); +class PidFileWiper { +public: + ~PidFileWiper() { + if (path.empty()) { + return; } - bool write( const string& p ) { - path = p; - ofstream out( path.c_str() , ios_base::out ); - out << ProcessId::getCurrent() << endl; - return out.good(); - } - - string path; - } pidFileWiper; + ofstream out(path.c_str(), ios_base::out); + out.close(); + } - bool writePidFile( const string& path ) { - bool e = pidFileWiper.write( path ); - if (!e) { - log() << "ERROR: Cannot write pid file to " << path - << ": "<< strerror(errno); - } - return e; + bool write(const string& p) { + path = p; + ofstream out(path.c_str(), ios_base::out); + out << ProcessId::getCurrent() << endl; + return out.good(); } - ProcessInfo::SystemInfo* ProcessInfo::systemInfo = NULL; + string path; +} pidFileWiper; - void ProcessInfo::initializeSystemInfo() { - if (systemInfo == NULL) { - systemInfo = new SystemInfo(); - } +bool writePidFile(const string& path) { + bool e = pidFileWiper.write(path); + if (!e) { + log() << "ERROR: Cannot write pid file to " << path << ": " << strerror(errno); } + return e; +} + +ProcessInfo::SystemInfo* ProcessInfo::systemInfo = NULL; - MONGO_INITIALIZER(SystemInfo)(InitializerContext* context) { - ProcessInfo::initializeSystemInfo(); - return Status::OK(); +void ProcessInfo::initializeSystemInfo() { + if (systemInfo == NULL) { + systemInfo = new SystemInfo(); } +} +MONGO_INITIALIZER(SystemInfo)(InitializerContext* context) { + ProcessInfo::initializeSystemInfo(); + return Status::OK(); +} } |