From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26603 invoked by alias); 9 Aug 2006 15:05:57 -0000 Received: (qmail 26584 invoked by uid 22791); 9 Aug 2006 15:05:57 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Aug 2006 15:05:54 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k79F5gSi031412; Wed, 9 Aug 2006 17:05:42 +0200 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k79F5gAB031411; Wed, 9 Aug 2006 17:05:42 +0200 Date: Wed, 09 Aug 2006 15:05:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix nice(3) errno values Message-ID: <20060809150542.GF4556@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00013.txt.bz2 Hi! POSIX documents EPERM for nice if nice argument (INCR) is negative and the process doesn't have enough priviledges to boost the process. But, setpriority that is used by nice internally uses EACCES for the same thing (reserving EPERM for when trying to set priority of other process not owned by the same owner). So I guess we should translate it like this: 2006-08-09 Jakub Jelinek * sysdeps/unix/nice.c (nice): Transform EACCES errno from setpriority to EPERM. --- libc/sysdeps/unix/nice.c.jj 2002-09-28 21:13:13.000000000 +0200 +++ libc/sysdeps/unix/nice.c 2006-08-09 16:56:42.000000000 +0200 @@ -1,4 +1,5 @@ -/* Copyright (C) 1992, 1996, 1997, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1996, 1997, 2001, 2002, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -42,9 +43,11 @@ nice (int incr) } result = setpriority (PRIO_PROCESS, 0, prio + incr); - if (result != -1) - return getpriority (PRIO_PROCESS, 0); - else - return -1; - + if (result == -1) + { + if (errno == EACCES) + errno = EPERM; + return -1; + } + return getpriority (PRIO_PROCESS, 0); } Jakub