Module Name: src Committed By: christos Date: Sun May 1 02:49:55 UTC 2011
Modified Files: src/lib/libc/gen: nice.c Log Message: nice should always return EPERM, not EACCES To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/nice.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/nice.c diff -u src/lib/libc/gen/nice.c:1.12 src/lib/libc/gen/nice.c:1.13 --- src/lib/libc/gen/nice.c:1.12 Thu Aug 7 12:42:53 2003 +++ src/lib/libc/gen/nice.c Sat Apr 30 22:49:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nice.c,v 1.12 2003/08/07 16:42:53 agc Exp $ */ +/* $NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: nice.c,v 1.12 2003/08/07 16:42:53 agc Exp $"); +__RCSID("$NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -53,16 +53,18 @@ * Backwards compatible nice. */ int -nice(incr) - int incr; +nice(int incr) { int prio; errno = 0; prio = getpriority(PRIO_PROCESS, 0); if (prio == -1 && errno) - return (-1); - if (setpriority(PRIO_PROCESS, 0, prio + incr) != 0) - return (-1); - return (getpriority(PRIO_PROCESS, 0)); + return -1; + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { + if (errno == EACCES) + errno = EPERM; + return -1; + } + return getpriority(PRIO_PROCESS, 0); }