diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-14 21:27:27 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-14 21:27:27 +0200 |
commit | f2bd3b5a194f8a751fddff0562b075524ba255dd (patch) | |
tree | dbe117d0099f599c2a0625661e36621f2699394f | |
parent | Implement libcoopgamma_get_methods (diff) | |
download | libcoopgamma-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>
-rw-r--r-- | src/libcoopgamma.c | 17 |
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; } |