From 787b261ffa5a1abca76b6ca4f8cc38373b9ccc2c Mon Sep 17 00:00:00 2001 From: Diego 'Flameeyes' Pettenò Date: Wed, 1 Oct 2008 13:26:32 +0200 Subject: Fix building on OpenSolaris (without _NSIG definition). On OpenSolaris, the _NSIG macro is not defined, but NSIG is; as it's not possible to use NSIG under glibc (it would miss the SIGRT* series), define a SIGNAL_UPPER_BOUND depending on the system (and error out if the system lacks both NSIG and _NSIG). --- libdaemon/dfork.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libdaemon/dfork.c b/libdaemon/dfork.c index f1ba7c1..6b94944 100644 --- a/libdaemon/dfork.c +++ b/libdaemon/dfork.c @@ -42,6 +42,14 @@ #include "dnonblock.h" #include "dlog.h" +#if defined(_NSIG) /* On glibc NSIG does not count RT signals */ +# define SIGNAL_UPPER_BOUND _NSIG +#elif defined(NSIG) /* Solaris defines just this */ +# define SIGNAL_UPPER_BOUND NSIG +#else +# error "Unknown upper bound for signals" +#endif + static int _daemon_retval_pipe[2] = { -1, -1 }; static int _null_open(int f, int fd) { @@ -665,7 +673,7 @@ int daemon_reset_sigs(int except, ...) { int daemon_reset_sigsv(const int except[]) { int sig; - for (sig = 1; sig < _NSIG; sig++) { + for (sig = 1; sig < SIGNAL_UPPER_BOUND; sig++) { int reset = 1; switch (sig) { -- cgit From b02e1b84803701d7bd65550f5435655696646b37 Mon Sep 17 00:00:00 2001 From: Diego 'Flameeyes' Pettenò Date: Wed, 1 Oct 2008 13:31:00 +0200 Subject: Conditionally declare variables if their use is conditional. Reduces warnings about unused variables by not declaring them if they are under an #ifdef conditional. --- libdaemon/dfork.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libdaemon/dfork.c b/libdaemon/dfork.c index 6b94944..62469bb 100644 --- a/libdaemon/dfork.c +++ b/libdaemon/dfork.c @@ -236,7 +236,9 @@ pid_t daemon_fork(void) { goto fail; } else if (pid == 0) { +#ifdef TIOCNOTTY int tty_fd; +#endif /* Second child */ if (sigaction(SIGCHLD, &sa_old, NULL) < 0) { @@ -478,9 +480,9 @@ int daemon_close_all(int except_fd, ...) { int daemon_close_allv(const int except_fds[]) { struct rlimit rl; int fd; - int saved_errno; #ifdef __linux__ + int saved_errno; DIR *d; -- cgit