about summary refs log tree commit diff
path: root/sysdeps/unix/nice.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/nice.c')
-rw-r--r--sysdeps/unix/nice.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sysdeps/unix/nice.c b/sysdeps/unix/nice.c
index 700305c0e9..1dd57fa5c0 100644
--- a/sysdeps/unix/nice.c
+++ b/sysdeps/unix/nice.c
@@ -41,7 +41,12 @@ nice (int incr)
 	__set_errno (save);
     }
 
-  result = setpriority (PRIO_PROCESS, 0, prio + incr);
+  prio += incr;
+  if (prio < PRIO_MIN)
+    prio = PRIO_MIN;
+  else if (prio >= PRIO_MAX)
+    prio = PRIO_MAX - 1;
+  result = setpriority (PRIO_PROCESS, 0, prio);
   if (result != -1)
     return getpriority (PRIO_PROCESS, 0);
   else