summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/inspircd.conf.example13
-rw-r--r--include/inspircd_io.h3
-rw-r--r--src/inspircd.cpp4
-rw-r--r--src/inspircd_io.cpp14
4 files changed, 32 insertions, 2 deletions
diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example
index bf2e7bc62..22031e957 100644
--- a/docs/inspircd.conf.example
+++ b/docs/inspircd.conf.example
@@ -238,14 +238,25 @@
<files motd="/home/cc/inspircd-1.0/conf/inspire.motd"
rules="/home/cc/inspircd-1.0/conf/inspire.rules">
-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- RTFM LINE -#-#-#-#-#-#-#-#-#-#-#-#-#-#
+#-#-#-#-#-#-#-#-#-#-#-#-#-#-# DNS SERVER -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# #
# Define your DNS server address here. InspIRCd has its own resolver #
# and you must define this otherwise nobody's host will resolve. The #
# timeout value is in seconds. #
+# #
<dns server="127.0.0.1" timeout="5">
+#-#-#-#-#-#-#-#-#-#-#-#-#-#-# PID FILE -#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
+# #
+# Define the path to the PID file here. The PID file can be used to #
+# rehash the ircd from the shell or to terminate the ircd from the #
+# shell using shell scripts, perl scripts etc, and to monitor the #
+# ircd's state via cron jobs. #
+# #
+
+<pid file="/path/to/inspircd.pid">
+
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- RTFM LINE -#-#-#-#-#-#-#-#-#-#-#-#-#-#
# #
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 2ff7568c0..fc10f7c32 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -15,6 +15,7 @@
*/
#include <sstream>
+#include <string>
void Exit (int);
void Start (void);
@@ -29,4 +30,4 @@ int ReadConf(std::stringstream *config_f,const char* tag, const char* var, int i
int ConfValueEnum(char* tag,std::stringstream *config);
int EnumConf(std::stringstream *config_f,const char* tag);
int EnumValues(std::stringstream *config, const char* tag, int index);
-
+void WritePID(std::string filename);
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index eda78a84b..d6bfb40e6 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -3386,6 +3386,10 @@ int InspIRCd(void)
Exit(ERROR);
}
}
+
+ char PID[MAXBUF];
+ ConfValue("pid","file",0,PID,&config_f);
+ WritePID(PID);
/* setup select call */
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 7a2ad99f8..19f853ddb 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -67,6 +67,20 @@ void Start (void)
printf("\033[1;37mName concept:\033[0;37m Lord_Zathras\n\n");
}
+void WritePID(std::string filename)
+{
+ ofstream outfile(filename.c_str());
+ if (outfile.is_open())
+ {
+ outfile << getpid();
+ outfile.close();
+ }
+ else
+ {
+ printf("Failed to write PID-file '%s', exiting.\n",filename.c_str());
+ Exit(0);
+ }
+}
void DeadPipe(int status)
{