From f2bd3b5a194f8a751fddff0562b075524ba255dd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 14 Jul 2016 21:27:27 +0200 Subject: Implement libcoopgamma_get_pid_file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libcoopgamma.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2