Expose __pidfile_path to override _PATH_VARRUN

This patch makes it possible to override the default pidfile() path used
for PID files, _PATH_VARRUN, with a custom path, e.g. _PATH_TMP.

This change does not affect the ABI of pidfile()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-06-06 12:14:26 +02:00
parent 12f619a320
commit c009c49a92
+2 -2
View File
@@ -45,6 +45,7 @@ static pid_t pidfile_pid;
static void pidfile_cleanup(void);
const char *__pidfile_path = _PATH_VARRUN; /* Note: includes trailing slash '/' */
const char *__pidfile_name = NULL;
extern char *__progname;
@@ -73,8 +74,7 @@ pidfile(const char *basename)
atexit_already = 1;
}
/* _PATH_VARRUN includes trailing / */
if (asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename) == -1)
if (asprintf(&pidfile_path, "%s%s.pid", __pidfile_path, basename) == -1)
return (-1);
if ((f = fopen(pidfile_path, "w")) == NULL) {