[Toybox] [Patch] Correction of nice levels in help.

Elie De Brauwer eliedebrauwer at gmail.com
Fri Feb 10 04:40:19 PST 2012


Hi all,

In the description of nice.c it is stated that 20 is the lowest priority 
while -19 is the highest priority. This should actually be 19 and -20. A 
patch for this is attached.

Below is a proof of concept that 20 and -21 are outside the valid range 
while 19 and -20 are within the valid range.

$ sudo strace -e getpriority,setpriority ./toybox nice -n 20 true
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 20)        = 0
getpriority(PRIO_PROCESS, 0)            = 1
getpriority(PRIO_PROCESS, 16383)        = 1
nice: Can't set priority
$ sudo strace -e getpriority,setpriority ./toybox nice -n 19 true
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 19)        = 0
getpriority(PRIO_PROCESS, 0)            = 1
getpriority(PRIO_PROCESS, 16386)        = 1
$ sudo strace -e getpriority,setpriority ./toybox nice -n -19 true
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, -19)       = 0
getpriority(PRIO_PROCESS, 0)            = 39
getpriority(PRIO_PROCESS, 16389)        = 39
$ sudo strace -e getpriority,setpriority ./toybox nice -n -20 true
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, -20)       = 0
getpriority(PRIO_PROCESS, 0)            = 40
getpriority(PRIO_PROCESS, 16392)        = 40
$ sudo strace -e getpriority,setpriority ./toybox nice -n -21 true
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, -21)       = 0
getpriority(PRIO_PROCESS, 0)            = 40
getpriority(PRIO_PROCESS, 16403)        = 40
nice: Can't set priority

my 2 cents
E.

-- 
Elie De Brauwer

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nice_help_correction.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20120210/9a01604d/attachment-0006.bin>


More information about the Toybox mailing list