]>
Commit | Line | Data |
---|---|---|
224c7076 A |
1 | Index: nice.c |
2 | =================================================================== | |
3 | RCS file: /cvs/root/Libc/gen/FreeBSD/nice.c,v | |
4 | retrieving revision 1.2 | |
5 | diff -u -d -b -w -p -r1.2 nice.c | |
6 | --- nice.c 2003/05/20 22:21:02 1.2 | |
7 | +++ nice.c 2005/04/06 22:28:10 | |
8 | @@ -42,7 +42,9 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/nic | |
9 | #include <sys/resource.h> | |
10 | #include <errno.h> | |
11 | #include <unistd.h> | |
12 | - | |
13 | +#if __DARWIN_UNIX03 | |
14 | +#include <limits.h> | |
15 | +#endif /* __DARWIN_UNIX03 */ | |
16 | /* | |
17 | * Backwards compatible nice. | |
18 | */ | |
19 | @@ -50,11 +52,18 @@ int | |
20 | nice(incr) | |
21 | int incr; | |
22 | { | |
23 | - int prio; | |
24 | + int prio, rv; | |
25 | ||
26 | errno = 0; | |
27 | prio = getpriority(PRIO_PROCESS, 0); | |
28 | if (prio == -1 && errno) | |
29 | return (-1); | |
30 | - return (setpriority(PRIO_PROCESS, 0, prio + incr)); | |
31 | +#if __DARWIN_UNIX03 | |
32 | + if (prio + incr > NZERO-1) | |
33 | + incr = NZERO-1-prio; | |
34 | +#endif /* __DARWIN_UNIX03 */ | |
35 | + rv = setpriority(PRIO_PROCESS, 0, prio + incr); | |
36 | + if (rv == -1 && errno == EACCES) | |
37 | + errno = EPERM; | |
38 | + return (rv == -1) ? rv : getpriority(PRIO_PROCESS, 0); | |
39 | } |