diff options
author | Matt Cotter <matt.cotter@mongodb.com> | 2016-01-28 16:25:59 -0500 |
---|---|---|
committer | Matt Cotter <matt.cotter@mongodb.com> | 2016-02-25 10:25:55 -0500 |
commit | 6f21482980d5a9be067d047f4601ad9ef8256d01 (patch) | |
tree | 9020f81eda275f785ec0f21c30191e2e8ad8605e /src/mongo/util/processinfo.cpp | |
parent | 4e87684433692889660c57763fa5c188651b646d (diff) | |
download | mongo-6f21482980d5a9be067d047f4601ad9ef8256d01.tar.gz |
SERVER-22364 threadsafe errno printing, pidfile error fix
If the errno is set after a pidfile write failure, then it will get
printed, otherwise this will print "Unable to determine OS error".
Diffstat (limited to 'src/mongo/util/processinfo.cpp')
-rw-r--r-- | src/mongo/util/processinfo.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/util/processinfo.cpp b/src/mongo/util/processinfo.cpp index 5a0e8dc798c..8afcb2f0eeb 100644 --- a/src/mongo/util/processinfo.cpp +++ b/src/mongo/util/processinfo.cpp @@ -58,6 +58,15 @@ public: path = p; ofstream out(path.c_str(), ios_base::out); out << ProcessId::getCurrent() << endl; + if (!out.good()) { + auto errAndStr = errnoAndDescription(); + if (errAndStr.first == 0) { + log() << "ERROR: Cannot write pid file to " << path + << ": Unable to determine OS error"; + } else { + log() << "ERROR: Cannot write pid file to " << path << ": " << errAndStr.second; + } + } return out.good(); } @@ -65,11 +74,7 @@ public: } pidFileWiper; bool writePidFile(const string& path) { - bool e = pidFileWiper.write(path); - if (!e) { - log() << "ERROR: Cannot write pid file to " << path << ": " << strerror(errno); - } - return e; + return pidFileWiper.write(path); } ProcessInfo::SystemInfo* ProcessInfo::systemInfo = NULL; |