|
Message-ID: <20130401151958.GL20323@brightrain.aerifal.cx> Date: Mon, 1 Apr 2013 11:19:58 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: setpriority typo On Mon, Apr 01, 2013 at 03:30:06PM +0100, Justin Cormack wrote: > On Mon, Apr 1, 2013 at 3:05 PM, Rich Felker <dalias@...ifal.cx> wrote: > > > On Mon, Apr 01, 2013 at 02:54:18PM +0100, Justin Cormack wrote: > > > cat ./src/misc/setpriority.c > > > #include <sys/resource.h> > > > #include "syscall.h" > > > > > > int setpriority(int which, id_t who, int prio) > > > { > > > return syscall(SYS_getpriority, which, who, prio); > > > } > > > > > > ^ should be set! > > > > This is definitely a bug, but I need to look at whether changing it > > will fix the problem. getpriority is doing some transformation on the > > prio value and I don't remember why, but it seems likely setpriority > > might need to do the same. > > > > Rich > > > > >From the man page: > > Within the kernel, nice values are actually represented using the > corresponding range 40..1 > (since negative numbers are error codes) and these are the values > employed by the setpriority() and getpriority() system > calls... The glibc wrapper functions for these system calls handle > the translations between the user-land and kernel repreā > sentations of the nice value according to the formula unice = 20 - > knice. > > So to be compatible with glibc there should be an adjustment. Reading the kernel source, apparently the adjustment is just required with getpriority to avoid it returning negative values on success. setpriority takes the unmodified value as an argument. BTW, these interfaces are badly nonconforming on Linux; they're affecting threads, not processes... I'm not clear what the conforming behavior would be on a system like Linux that does not support system scheduling scope, but unfortunately it's probably not what anybody wants or expects... Anyway I'll fix the bug for now, then we can discuss whether these interfaces need changing. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.