X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=daemon.c;fp=daemon.c;h=478b0f47acc94d3098cc17576599032f007b43ca;hp=94c4a8cba6b9aae8646491f3eeddfff016914c7b;hb=bbd70648da0f4168df34c1f1651d67af089e7be6;hpb=486314426fcd25e5271fd65a982f8b321585e195 diff --git a/daemon.c b/daemon.c index 94c4a8cb..478b0f47 100644 --- a/daemon.c +++ b/daemon.c @@ -11,6 +11,7 @@ #include /* getgrnam() */ #include #include +#include #include "para.h" #include "daemon.h" @@ -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. *