aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcoopgamma.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-14 21:27:27 +0200
committerMattias Andrée <maandree@kth.se>2016-07-14 21:27:27 +0200
commitf2bd3b5a194f8a751fddff0562b075524ba255dd (patch)
treedbe117d0099f599c2a0625661e36621f2699394f /src/libcoopgamma.c
parentImplement libcoopgamma_get_methods (diff)
downloadlibcoopgamma-f2bd3b5a194f8a751fddff0562b075524ba255dd.tar.gz
libcoopgamma-f2bd3b5a194f8a751fddff0562b075524ba255dd.tar.bz2
libcoopgamma-f2bd3b5a194f8a751fddff0562b075524ba255dd.tar.xz
Implement libcoopgamma_get_pid_file
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/libcoopgamma.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libcoopgamma.c b/src/libcoopgamma.c
index b024f52..a20a4e1 100644
--- a/src/libcoopgamma.c
+++ b/src/libcoopgamma.c
@@ -906,6 +906,23 @@ int libcoopgamma_get_method_and_site(const char* restrict method, const char* re
*/
char* libcoopgamma_get_pid_file(const char* restrict method, const char* restrict site)
{
+ char* path;
+ size_t n;
+
+ path = libcoopgamma_get_socket_file(method, site);
+ if (path == NULL)
+ return NULL;
+
+ n = strlen(path);
+ if (n < 7 || strcmp(path + n - 7, ".socket"))
+ {
+ free(path);
+ errno = EBADMSG;
+ return NULL;
+ }
+
+ strcpy(path + n - 7, ".pid");
+ return path;
}