Use the more portable NZERO instead of PRIO_*
We assume the valid range is [-NZERO, NZERO-1].
This commit is contained in:
parent
2773bdaac7
commit
795ffe490d
2
nice.c
2
nice.c
|
@ -32,7 +32,7 @@ main(int argc, char **argv)
|
||||||
val += getpriority(PRIO_PROCESS, 0);
|
val += getpriority(PRIO_PROCESS, 0);
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
weprintf("getpriority:");
|
weprintf("getpriority:");
|
||||||
val = MAX(PRIO_MIN, MIN(val, PRIO_MAX));
|
val = MAX(-NZERO, MIN(val, NZERO - 1));
|
||||||
if (setpriority(PRIO_PROCESS, 0, val) != 0)
|
if (setpriority(PRIO_PROCESS, 0, val) != 0)
|
||||||
weprintf("setpriority:");
|
weprintf("setpriority:");
|
||||||
|
|
||||||
|
|
2
renice.c
2
renice.c
|
@ -100,7 +100,7 @@ renice(int which, int who, long adj)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
adj = MAX(PRIO_MIN, MIN(adj, PRIO_MAX));
|
adj = MAX(-NZERO, MIN(adj, NZERO - 1));
|
||||||
if(setpriority(which, who, (int)adj) == -1) {
|
if(setpriority(which, who, (int)adj) == -1) {
|
||||||
fprintf(stderr, "can't set %d nice level: %s\n",
|
fprintf(stderr, "can't set %d nice level: %s\n",
|
||||||
who, strerror(errno));
|
who, strerror(errno));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user