summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-27 07:13:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-27 07:13:22 +0000
commit90f3d27affadff9b7b2ba6c5d4014c206e0a178e (patch)
treeb3dc7472f1a6851811e6c78a81f82578cf8e78e3 /src
parent6bc7d2c1ecd6a79545fdf83a9b8b054190d56ed2 (diff)
Allow relative path on pid file
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5547 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/inspircd.cpp17
2 files changed, 15 insertions, 4 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index e0e249963..0dd5745d1 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -1279,7 +1279,7 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname)
if((pos = confpath.find("/inspircd.conf")) != std::string::npos)
{
/* Leaves us with just the path */
- std::string newfile = confpath.substr(0, pos) + std::string("/") + newfile;
+ std::string newfile = confpath.substr(0, pos) + std::string("/") + fname;
file = fopen(newfile.c_str(), "r");
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index df4cfe754..421b91ebe 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -148,7 +148,18 @@ bool InspIRCd::DaemonSeed()
void InspIRCd::WritePID(const std::string &filename)
{
- std::ofstream outfile(filename.c_str());
+ std::string fname = (filename.empty() ? "inspircd.pid" : filename);
+ if (*(fname.begin()) != '/')
+ {
+ std::string::size_type pos;
+ std::string confpath = CONFIG_FILE;
+ if ((pos = confpath.find("/inspircd.conf")) != std::string::npos)
+ {
+ /* Leaves us with just the path */
+ fname = confpath.substr(0, pos) + std::string("/") + fname;
+ }
+ }
+ std::ofstream outfile(fname.c_str());
if (outfile.is_open())
{
outfile << getpid();
@@ -156,8 +167,8 @@ void InspIRCd::WritePID(const std::string &filename)
}
else
{
- printf("Failed to write PID-file '%s', exiting.\n",filename.c_str());
- this->Log(DEFAULT,"Failed to write PID-file '%s', exiting.",filename.c_str());
+ printf("Failed to write PID-file '%s', exiting.\n",fname.c_str());
+ this->Log(DEFAULT,"Failed to write PID-file '%s', exiting.",fname.c_str());
Exit(0);
}
}