From 8846e58f99cd0774ea00dbbecf0053d62403214d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 25 Jan 2011 10:33:36 +0000 Subject: [PATCH] undo --- src/util/os_priority.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 3993f572c..e9ca9deea 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -320,11 +320,32 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, SetPriorityClass (h, rprio); } #elif LINUX - if (0 != setpriority (PRIO_PROCESS, proc->pid, rprio)) + pid_t pid; + + pid = proc->pid; + if ( (0 == pid) || + (pid == getpid () ) ) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, "setpriority"); - return GNUNET_SYSERR; + int have = nice (0); + int delta = rprio - have; + errno = 0; + if ( (delta != 0) && + (rprio == nice (delta)) && + (errno != 0) ) + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | + GNUNET_ERROR_TYPE_BULK, "nice"); + return GNUNET_SYSERR; + } + } + else + { + if (0 != setpriority (PRIO_PROCESS, pid, rprio)) + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | + GNUNET_ERROR_TYPE_BULK, "setpriority"); + return GNUNET_SYSERR; + } } #else GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, -- 2.25.1