From 98d0f8f89e8db203226c657e8400a250182ac274 Mon Sep 17 00:00:00 2001 From: Babak Farrokhi Date: Tue, 27 Oct 2015 11:01:43 +0330 Subject: [PATCH] - Fix linux build --- pidutil.c | 8 +++++++- pidutil.h | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pidutil.c b/pidutil.c index d6eee11..70f112d 100644 --- a/pidutil.c +++ b/pidutil.c @@ -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); diff --git a/pidutil.h b/pidutil.h index a8d3f82..d1975d7 100644 --- a/pidutil.h +++ b/pidutil.h @@ -1,6 +1,10 @@ #ifndef _PIDUTIL_H #define _PIDUTIL_H +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include #include #include @@ -16,6 +20,7 @@ #include #include #include +#include struct pidfh;