diff options
author | Fred Wright <fw@fwright.net> | 2017-01-22 01:44:19 -0800 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2017-01-22 14:02:55 -0800 |
commit | 2cb17f91607bdfd9cd7ad80f7232db8b1bd23d34 (patch) | |
tree | 452241687896ffdf45d2a002478bf970d67ec7a0 /os_compat.h | |
parent | cb1403d842a2fdbe6109eaf48acb7a494f30784d (diff) | |
download | gpsd-2cb17f91607bdfd9cd7ad80f7232db8b1bd23d34.tar.gz |
Centralizes daemon() calls.
This defines a new function os_daemon() (in os_compat.c), which is
either the old replacement daemon() renamed, or a wrapper around the
actual daemon() call. This allows any issues related to daemon()
(which exist on some platforms) to be dealt with in one place. No
such changes are present yet, so platforms giving warnings for the use
of daemon() continue to do so, but now only in the compilation of
os_compat.c. Unfortunately, the current build procedure typically
compiles os_compat.c multiple times, so the warnings still appear
multiple times.
TESTED:
Ran "scons build-all check" on OSX 10.9, OSX 10.12, Ubuntu 14, and
FreeBSD 10.3.
Diffstat (limited to 'os_compat.h')
-rw-r--r-- | os_compat.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/os_compat.h b/os_compat.h index 4dbe9de3..93ea8b06 100644 --- a/os_compat.h +++ b/os_compat.h @@ -17,6 +17,8 @@ extern "C" { #ifndef HAVE_CLOCK_GETTIME +/* Simulate ANSI/POSIX clock_gettime() on platforms that don't have it */ + #include <time.h> #ifndef CLOCKID_T_DEFINED @@ -46,6 +48,17 @@ int clock_gettime(clockid_t, struct timespec *); #endif /* !HAVE_CLOCK_GETTIME */ +/* + * Wrapper or substitute for Linux/BSD daemon() + * + * There are some issues with this function even when it's present, so + * wrapping it confines the issues to a single place in os_compat.c. + */ + +int os_daemon(int nochdir, int noclose); + +/* Provide BSD strlcat()/strlcpy() on platforms that don't have it */ + #ifndef HAVE_STRLCAT #include <string.h> |