summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/server/ServerControl.cpp24
-rw-r--r--lib/server/ServerControl.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/server/ServerControl.cpp b/lib/server/ServerControl.cpp
index 47b1cc5f..d4d44c70 100644
--- a/lib/server/ServerControl.cpp
+++ b/lib/server/ServerControl.cpp
@@ -227,6 +227,30 @@ bool KillServer(int pid, bool WaitForProcess)
return !ServerIsAlive(pid);
}
+bool KillServer(std::string pid_file, bool WaitForProcess)
+{
+ FileStream fs(pid_file);
+ IOStreamGetLine getline(fs);
+ std::string line = getline.GetLine();
+ int pid = atoi(line.c_str());
+ bool status = KillServer(pid, WaitForProcess);
+ TEST_EQUAL_LINE(true, status, std::string("kill(") + pid_file + ")");
+
+#ifdef WIN32
+ if(WaitForProcess)
+ {
+ int unlink_result = unlink(pid_file.c_str());
+ TEST_EQUAL_LINE(0, unlink_result, std::string("unlink ") + pid_file);
+ if(unlink_result != 0)
+ {
+ return false;
+ }
+ }
+#endif
+
+ return status;
+}
+
int StartDaemon(int current_pid, const std::string& cmd_line, const char* pid_file)
{
TEST_THAT_OR(current_pid == 0, return 0);
diff --git a/lib/server/ServerControl.h b/lib/server/ServerControl.h
index 430f03a3..be2464c1 100644
--- a/lib/server/ServerControl.h
+++ b/lib/server/ServerControl.h
@@ -5,6 +5,7 @@
bool HUPServer(int pid);
bool KillServer(int pid, bool WaitForProcess = false);
+bool KillServer(std::string pid_file, bool WaitForProcess = false);
int StartDaemon(int current_pid, const std::string& cmd_line, const char* pid_file);
bool StopDaemon(int current_pid, const std::string& pid_file,
const std::string& memleaks_file, bool wait_for_process);