summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c22
-rw-r--r--src/run.c4
2 files changed, 22 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 831a3c2..dafeaee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <string.h>
@@ -112,6 +113,23 @@ set_action_by_table(int i, int argc, char *argv[],
return i;
}
+static void
+set_nice_value(int nv)
+{
+ errno = 0;
+ if (nice(nv) == -1 && errno) /* warn only */
+ fprintf(stderr, "Cannot set nice level %d: %s\n",
+ nv, strerror(errno));
+}
+
+static void
+do_chdir(const char *d)
+{
+ if (chdir(d))
+ fprintf(stderr, "Cannot change current directory to %s: %s\n",
+ d, strerror(errno));
+}
+
int main(int argc, char *argv[])
{
int ret, i, action = -1;
@@ -356,7 +374,7 @@ int main(int argc, char *argv[])
/*
* Setting process priority and scheduler
*/
- nice(CONFIG(nice));
+ set_nice_value(CONFIG(nice));
if (CONFIG(sched).type != SCHED_OTHER) {
struct sched_param schedparam = {
@@ -382,7 +400,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- chdir("/");
+ do_chdir("/");
close(STDIN_FILENO);
/* Daemonize conntrackd */
diff --git a/src/run.c b/src/run.c
index 44a179f..7fa6889 100644
--- a/src/run.c
+++ b/src/run.c
@@ -40,14 +40,14 @@
#include <time.h>
#include <fcntl.h>
-void killer(int signal)
+void killer(int signo)
{
/* Signals are re-entrant, disable signal handling to avoid problems
* in case we receive SIGINT and SIGTERM in a row. This function is
* also called via -k from the unix socket context, we already disabled
* signals in that path, so don't do it.
*/
- if (signal)
+ if (signo)
sigprocmask(SIG_BLOCK, &STATE(block), NULL);
local_server_destroy(&STATE(local));