From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3029 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: setpriority typo Date: Mon, 1 Apr 2013 11:19:58 -0400 Message-ID: <20130401151958.GL20323@brightrain.aerifal.cx> References: <20130401140504.GK20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1364829608 13040 80.91.229.3 (1 Apr 2013 15:20:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Apr 2013 15:20:08 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3030-gllmg-musl=m.gmane.org@lists.openwall.com Mon Apr 01 17:20:36 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UMgXE-0002AY-Fo for gllmg-musl@plane.gmane.org; Mon, 01 Apr 2013 17:20:36 +0200 Original-Received: (qmail 15913 invoked by uid 550); 1 Apr 2013 15:20:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15905 invoked from network); 1 Apr 2013 15:20:10 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3029 Archived-At: On Mon, Apr 01, 2013 at 03:30:06PM +0100, Justin Cormack wrote: > On Mon, Apr 1, 2013 at 3:05 PM, Rich Felker wrote: > > > On Mon, Apr 01, 2013 at 02:54:18PM +0100, Justin Cormack wrote: > > > cat ./src/misc/setpriority.c > > > #include > > > #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