diff --git a/include/limits.h b/include/limits.h index ec18dd7127..28f02c4254 100644 --- a/include/limits.h +++ b/include/limits.h @@ -276,10 +276,10 @@ #define NL_TEXTMAX _POSIX2_LINE_MAX /* NZERO - * Default process priority. Minimum Acceptable Value: 20 + * Default process priority. Minimum Acceptable Value: 128 */ -#define NZERO 20 +#define NZERO 128 /* Required for asynchronous I/O */ diff --git a/libs/libc/unistd/lib_getpriority.c b/libs/libc/unistd/lib_getpriority.c index 95996d2313..44d9c8d8ed 100644 --- a/libs/libc/unistd/lib_getpriority.c +++ b/libs/libc/unistd/lib_getpriority.c @@ -82,5 +82,9 @@ int getpriority(int which, id_t who) return ret; } - return param.sched_priority; + /* Since -1 is a legal return value, clear errno to avoid the chaos */ + + set_errno(0); + + return NZERO - param.sched_priority; } diff --git a/libs/libc/unistd/lib_setpriority.c b/libs/libc/unistd/lib_setpriority.c index 057f05fa73..d02c7af41e 100644 --- a/libs/libc/unistd/lib_setpriority.c +++ b/libs/libc/unistd/lib_setpriority.c @@ -69,7 +69,7 @@ int setpriority(int which, id_t who, int value) return ret; } - param.sched_priority = value; + param.sched_priority = NZERO - value; return sched_setparam(who, ¶m); }