X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=daemon.c;h=945c5a39a094e8314c5667f57f0b6a8099b12b45;hp=ca74595695985ad866c6ad849cbc343e2801850a;hb=f2940b2fbde865256bc35c74e3bd624d2ff48d2e;hpb=db212616a42fb6d33385f79cfc9b8cca9721a8b9 diff --git a/daemon.c b/daemon.c index ca745956..945c5a39 100644 --- a/daemon.c +++ b/daemon.c @@ -11,6 +11,7 @@ #include /* getgrnam() */ #include #include +#include #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); } @@ -121,7 +122,7 @@ void daemon_init_colors_or_die(int color_arg, int color_arg_auto, * * \param logfile_name The full path of the logfile. */ -void daemon_set_logfile(char *logfile_name) +void daemon_set_logfile(const char *logfile_name) { free(me->logfile_name); me->logfile_name = NULL; @@ -134,7 +135,7 @@ void daemon_set_logfile(char *logfile_name) * * \param loglevel The smallest level that should be logged. */ -void daemon_set_loglevel(char *loglevel) +void daemon_set_loglevel(const char *loglevel) { int ret = get_loglevel_by_name(loglevel); @@ -249,11 +250,30 @@ void daemon_open_log_or_die(void) /** * Log the startup message containing the paraslash version. + * + * \param name The name of the executable. + * + * First the given \a name is prefixed with the string "para_". Next the git + * version is appended. The resulting string is logged with priority "INFO". + */ +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_log_welcome(const char *whoami) +void daemon_set_priority(int prio) { - PARA_INFO_LOG("welcome to %s " PACKAGE_VERSION " ("BUILD_DATE")\n", - whoami); + if (setpriority(PRIO_PROCESS, 0, prio) < 0) + PARA_WARNING_LOG("could not set priority to %d: %s\n", prio, + strerror(errno)); } /**