aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-08-16 22:24:30 -0500
committerRob Landley <rob@landley.net>2012-08-16 22:24:30 -0500
commit734206bd09aaba9c3175be557e4f35b095df1ccf (patch)
tree52c3bc4f64a8c63826df1c9daf7df5696ea6b8f0
parentc96444da80b7db3bd5d7c3e05e15f973840378c6 (diff)
downloadtoybox-734206bd09aaba9c3175be557e4f35b095df1ccf.tar.gz
Bugfix from Avery Pennarun: getpriority() uses a different range than nice(), so follow thenice man page and zero errno then check it if nice returns -1.
-rw-r--r--toys/nice.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/nice.c b/toys/nice.c
index 0be74886..84975dfc 100644
--- a/toys/nice.c
+++ b/toys/nice.c
@@ -34,9 +34,8 @@ void nice_main(void)
{
if (!toys.optflags) TT.priority = 10;
- nice(TT.priority);
- if (getpriority(PRIO_PROCESS, getpid()) != TT.priority)
- perror_exit("Can't set priority");
+ errno = 0;
+ if (nice(TT.priority)==-1 && errno) perror_exit("Can't set priority");
xexec(toys.optargs);
}