- Fix linux build

This commit is contained in:
Babak Farrokhi 2015-10-27 11:01:43 +03:30
parent a85a6ce909
commit 98d0f8f89e
2 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,12 @@ struct pidfh {
static int _pidfile_remove(struct pidfh *pfh, int freeit);
#ifdef __linux__
#define PROGNAME program_invocation_short_name
#else
#define PROGNAME getprogname()
#endif /* __linux__ */
static int
pidfile_verify(const struct pidfh *pfh)
{
@ -133,7 +139,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
return NULL;
if (path == NULL)
len = snprintf(pfh->pf_path, sizeof(pfh->pf_path), "/var/run/%s.pid", getprogname());
len = snprintf(pfh->pf_path, sizeof(pfh->pf_path), "/var/run/%s.pid", PROGNAME);
else
len = snprintf(pfh->pf_path, sizeof(pfh->pf_path), "%s", path);

View File

@ -1,6 +1,10 @@
#ifndef _PIDUTIL_H
#define _PIDUTIL_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/file.h>
#include <sys/param.h>
#include <sys/stat.h>
@ -16,6 +20,7 @@
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <errno.h>
struct pidfh;