public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix nice(3) errno values
@ 2006-08-09 15:05 Jakub Jelinek
  2006-08-15  5:25 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2006-08-09 15:05 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix nice(3) errno values
  2006-08-09 15:05 [PATCH] Fix nice(3) errno values Jakub Jelinek
@ 2006-08-15  5:25 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2006-08-15  5:25 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-15  5:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-09 15:05 [PATCH] Fix nice(3) errno values Jakub Jelinek
2006-08-15  5:25 ` Ulrich Drepper

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).