summaryrefslogtreecommitdiff
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 eb26c43a60..6e75b0327b 100644
--- a/sysdeps/unix/nice.c
+++ b/sysdeps/unix/nice.c
@@ -42,7 +42,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)
{
if (errno == EACCES)