rk_pidfile() should call pidfile() if HAVE_PIDFILE
This is necessary so we can use --detach in tests even on NetBSD and OpenBSD.
This commit is contained in:
@@ -163,6 +163,7 @@ roken_detach_finish(const char *dir, int daemon_child_fd)
|
||||
ssize_t bytes;
|
||||
int fd;
|
||||
|
||||
pidfile(NULL);
|
||||
if (pipefds[1] == -1 && daemon_child_fd != -1)
|
||||
pipefds[1] = daemon_child_fd;
|
||||
if (pipefds[0] != -1)
|
||||
|
@@ -756,14 +756,12 @@ ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
|
||||
readv(int, const struct iovec *, int);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PIDFILE
|
||||
#ifdef NO_PIDFILES
|
||||
#define pidfile(x) ((void) 0)
|
||||
#else
|
||||
#define pidfile rk_pidfile
|
||||
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BSWAP64
|
||||
#define bswap64 rk_bswap64
|
||||
|
@@ -76,7 +76,6 @@ pid_file_delete(char **filename)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_PIDFILE
|
||||
static char *pidfile_path;
|
||||
|
||||
static void
|
||||
@@ -89,15 +88,26 @@ pidfile_cleanup(void)
|
||||
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
|
||||
pidfile(const char *bname)
|
||||
{
|
||||
/*
|
||||
* If the OS has a pidfile(), call that, but still call
|
||||
* pid_file_write(). Even if both want to write the same file,
|
||||
* writing it twice will still work.
|
||||
*/
|
||||
#ifdef HAVE_PIDFILE
|
||||
#undef pidfile
|
||||
pidfile(bname);
|
||||
#endif
|
||||
|
||||
if (pidfile_path != NULL)
|
||||
return;
|
||||
if (bname == NULL)
|
||||
bname = getprogname();
|
||||
pidfile_path = pid_file_write(bname);
|
||||
#if defined(HAVE_ATEXIT)
|
||||
atexit(pidfile_cleanup);
|
||||
if (pidfile_path != NULL)
|
||||
atexit(pidfile_cleanup);
|
||||
#elif defined(HAVE_ON_EXIT)
|
||||
on_exit(pidfile_cleanup);
|
||||
if (pidfile_path != NULL)
|
||||
on_exit(pidfile_cleanup);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user