]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - daemon.c
Merge branch 'refs/heads/t/i9e'
[paraslash.git] / daemon.c
index 94c4a8cba6b9aae8646491f3eeddfff016914c7b..5a92451a4d0621f5c1abb8c8961a878132e8f4e3 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -11,6 +11,7 @@
 #include <sys/types.h> /* getgrnam() */
 #include <grp.h>
 #include <signal.h>
+#include <sys/resource.h>
 
 #include "para.h"
 #include "daemon.h"
@@ -73,7 +74,7 @@ static void daemon_set_log_color_or_die(char const *arg)
        color_parse_or_die(p, me->log_colors[ll]);
        return;
 err:
-       PARA_EMERG_LOG("%s: color syntax error\n", arg);
+       PARA_EMERG_LOG("%s: invalid color argument\n", arg);
        exit(EXIT_FAILURE);
 }
 
@@ -260,6 +261,21 @@ void daemon_log_welcome(const char *name)
        PARA_INFO_LOG("welcome to para_%s-" PACKAGE_VERSION " \n", name);
 }
 
+/**
+ * Renice the calling process.
+ *
+ * \param prio The priority value to set.
+ *
+ * Errors are not considered fatal, but a warning message is logged if the
+ * underlying call to setpriority(2) fails.
+ */
+void daemon_set_priority(int prio)
+{
+       if (setpriority(PRIO_PROCESS, 0, prio) < 0)
+               PARA_WARNING_LOG("could not set priority to %d: %s\n", prio,
+                       strerror(errno));
+}
+
 /**
  * Give up superuser privileges.
  *