diff options
author | Alexander Wirt <formorer@debian.org> | 2014-09-19 10:15:13 +0200 |
---|---|---|
committer | Alexander Wirt <formorer@debian.org> | 2014-09-19 10:15:13 +0200 |
commit | 9f760e5d3f6b44ecf5bb7144517e022fd987fa76 (patch) | |
tree | a19ccbfccc5049ee3a8252725191af221f31b3ea /src/main.c | |
parent | 6b61aefbf3de71852386f5f26d60c10ef62407d3 (diff) | |
download | conntrack-tools-9f760e5d3f6b44ecf5bb7144517e022fd987fa76.tar.gz conntrack-tools-9f760e5d3f6b44ecf5bb7144517e022fd987fa76.zip |
Imported Upstream version 1.4.2
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -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 */ |