diff options
Diffstat (limited to 'cpp/src/Ice/Instance.cpp')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index fec1e81d106..0ce1f2ed719 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -81,6 +81,8 @@ public: static GlobalStateMutexDestroyer destroyer; +volatile bool Instance::_printProcessIdDone = false; + } void IceInternal::incRef(Instance* p) { p->__incRef(); } @@ -627,15 +629,20 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) } // - // Show process id if requested. + // Show process id if requested (but only once). // - if(_properties->getPropertyAsInt("Ice.PrintProcessId") > 0) + if(!_printProcessIdDone && _properties->getPropertyAsInt("Ice.PrintProcessId") > 0) { + IceUtil::RecMutex::Lock sync(*this); // Double-checked locking + if(!_printProcessIdDone) + { #ifdef _WIN32 - cout << _getpid() << endl; + cout << _getpid() << endl; #else - cout << getpid() << endl; + cout << getpid() << endl; #endif + _printProcessIdDone = true; + } } // |