diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-11 16:49:36 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-11 16:49:36 +0200 |
commit | 5fedc38518bb9198e23ad8ee7c435b06be7b7026 (patch) | |
tree | 04bf17acb1547f7f035202e201e5a9afe6e295cd /src | |
parent | Close file descriptors (diff) | |
download | coopgammad-5fedc38518bb9198e23ad8ee7c435b06be7b7026.tar.gz coopgammad-5fedc38518bb9198e23ad8ee7c435b06be7b7026.tar.bz2 coopgammad-5fedc38518bb9198e23ad8ee7c435b06be7b7026.tar.xz |
Do not require /proc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/gammad.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gammad.c b/src/gammad.c index 5450399..92fbf4d 100644 --- a/src/gammad.c +++ b/src/gammad.c @@ -229,9 +229,13 @@ static int is_pidfile_reusable(const char* pidfile, const char* token) int fd = -1, saved_errno, tries = 0; char* content = NULL; char* p; - char* end; pid_t pid = 0; size_t n; +#if defined(HAVE_LINUX_PROCFS) + char* end; +#else + (void) token; +#endif /* Get PID */ retry: @@ -271,6 +275,7 @@ static int is_pidfile_reusable(const char* pidfile, const char* token) goto bad; /* Validate PID */ +#if defined(HAVE_LINUX_PROCFS) sprintf(temp, "/proc/%llu/environ", (unsigned long long)pid); fd = open(temp, O_RDONLY); if (fd < 0) @@ -283,6 +288,10 @@ static int is_pidfile_reusable(const char* pidfile, const char* token) for (end = (p = content) + n; p != end; p = strchr(p, '\0') + 1) if (!strcmp(p, token)) return 0; +#else + if ((kill(pid, 0) == 0) || (errno == EINVAL)) + return 0; +#endif return 1; bad: |