The OpenBSD version of pidfile() makes sure to place all PID files in
the same, canonical, location: _PATH_VARRUN. On Linux, however, some
disitributions prefer to place PID files in a sub-directory under the
canonical location: _PATH_VARRUN + __progname/ ...
This patch adds support for creating PID files in any location. If the
PID file name argument starts with a '/', the function assumes the rest
of the string is the full PATH to the PID file.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Always initialize global variables, even though they cannot be used in
current code paths without being initialized at runtime.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
To prevent warnings from tools like Valgrind, or handle issues
with RAM leaks on non-MMU systems like uClinux, we must free
the memory allocated by pidfile().
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>
Due to problems with the unit tests the use of utimensat() in pidfile()
was disabled, and forgotten. This patch enables it, but beware, this
thing is QUICK on any system with a L2 cache or better.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch update the `-lite` patch to OpenBSD `pidfile()` by changing
the update atime+mtime patch from writing the PID again to instead use
utimensat(). Less overhead and nanosecond resolution.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Do not assume that asprintf() clears the pointer on failure, which
is non-portable. Also add missing asprintf() return value checks.
Signed-off-by: millert@
Signed-off-by: deraadt@ guenther@ doug@
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>