public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix nice(3) errno values
Date: Wed, 09 Aug 2006 15:05:00 -0000	[thread overview]
Message-ID: <20060809150542.GF4556@sunsite.mff.cuni.cz> (raw)

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  <jakub@redhat.com>

	* 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

             reply	other threads:[~2006-08-09 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09 15:05 Jakub Jelinek [this message]
2006-08-15  5:25 ` Ulrich Drepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060809150542.GF4556@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).