1 --- nice.c.orig 2009-11-07 14:51:38.000000000 -0800
2 +++ nice.c 2009-11-07 14:51:40.000000000 -0800
3 @@ -38,7 +38,9 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/nic
4 #include <sys/resource.h>
10 +#endif /* __DARWIN_UNIX03 */
12 * Backwards compatible nice.
14 @@ -46,11 +48,18 @@ int
22 prio = getpriority(PRIO_PROCESS, 0);
23 if (prio == -1 && errno)
25 - return (setpriority(PRIO_PROCESS, 0, prio + incr));
27 + if (prio + incr > NZERO-1)
28 + incr = NZERO-1-prio;
29 +#endif /* __DARWIN_UNIX03 */
30 + rv = setpriority(PRIO_PROCESS, 0, prio + incr);
31 + if (rv == -1 && errno == EACCES)
33 + return (rv == -1) ? rv : getpriority(PRIO_PROCESS, 0);