From b0fe419fa0f83ab3755367c1803167568a11a722 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 2 Apr 2005 18:08:53 +0000 Subject: Added pid file support, and documentation for it git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@950 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 4 ++++ src/inspircd_io.cpp | 14 ++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3