From 8a9ddda247e1c41eecc213612da7900a3db5ae8b Mon Sep 17 00:00:00 2001 From: psychon Date: Sat, 8 Sep 2007 16:22:10 +0000 Subject: [PATCH] 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 --- znc.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/znc.cpp b/znc.cpp index 8978a8d1..15b711ca 100644 --- a/znc.cpp +++ b/znc.cpp @@ -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;