aboutsummaryrefslogtreecommitdiff
path: root/tests/server/util.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-02-26 15:06:44 +0000
committerYang Tse <yangsita@gmail.com>2008-02-26 15:06:44 +0000
commit0d09f342c48b0d447fd506869959986da1746838 (patch)
treede9eead14a1ce4be7ecfd1039a30f6ad41f1014c /tests/server/util.c
parent9682c2037e964cd64ba581ceff61a04bb6395a6b (diff)
refactor some code out to write_pidfile() in util.c
Diffstat (limited to 'tests/server/util.c')
-rw-r--r--tests/server/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/server/util.c b/tests/server/util.c
index 15a4e60e1..66210a50e 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -222,3 +222,19 @@ int wait_ms(int timeout_ms)
return r;
}
+bool write_pidfile(const char *filename)
+{
+ FILE *pidfile;
+ long pid;
+
+ pid = (long)getpid();
+ pidfile = fopen(filename, "w");
+ if(!pidfile) {
+ logmsg("Couldn't write pid file: %s %s", filename, strerror(ERRNO));
+ return FALSE;
+ }
+ fprintf(pidfile, "%ld\n", pid);
+ fclose(pidfile);
+ logmsg("Wrote pid %ld to %s", pid, filename);
+ return true;
+}