Only expand the PidFile config option when writing the pid file.

This way if we rewrite the config PidFile gets the same value it had when znc
was started.
-> we don't turn it into an absolute path which is bad if data dir is changed


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@839 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2007-09-08 16:22:10 +00:00
parent 67ae390458
commit 8a9ddda247

19
znc.cpp
View File

@@ -241,8 +241,16 @@ void CZNC::ReleaseISpoof() {
bool CZNC::WritePidFile(int iPid) {
if (!m_sPidFile.empty()) {
CFile File(m_sPidFile);
CUtils::PrintAction("Writing pid file [" + m_sPidFile + "]");
CString sFile;
// absolute path or relative to the data dir?
if (m_sPidFile[0] != '/')
sFile = GetZNCPath() + "/" + m_sPidFile;
else
sFile = m_sPidFile;
CFile File(sFile);
CUtils::PrintAction("Writing pid file [" + sFile + "]");
if (File.Open(O_WRONLY | O_TRUNC | O_CREAT)) {
File.Write(CString(iPid) + "\n");
@@ -1174,12 +1182,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
AddVHost(sValue);
continue;
} else if (sName.CaseCmp("PidFile") == 0) {
if (!sValue.empty() && sValue[0] != '/') {
m_sPidFile = GetZNCPath() + "/" + sValue;
} else {
m_sPidFile = sValue;
}
m_sPidFile = sValue;
continue;
} else if (sName.CaseCmp("StatusPrefix") == 0) {
m_sStatusPrefix = sValue;