diff --git a/libs/libc/unistd/lib_getpriority.c b/libs/libc/unistd/lib_getpriority.c index 03747a4b340..0029743c7d5 100644 --- a/libs/libc/unistd/lib_getpriority.c +++ b/libs/libc/unistd/lib_getpriority.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include #include @@ -46,7 +47,13 @@ * Returned Value: * Upon successful completion, getpriority() shall return an integer in * the range -{NZERO} to {NZERO}-1. Otherwise, -1 shall be returned and - * errno set to indicate the error. + * errno set to indicate the error. The following errors may be + * reported: + * + * - ESRCH: No process was located using the which and who values + * specified. + * - EINVAL: which was not one of PRIO_PROCESS, PRIO_PGRP, or + * PRIO_USER. * * Assumptions: * @@ -57,6 +64,12 @@ int getpriority(int which, id_t who) struct sched_param param; int ret; + if (which > PRIO_USER || which < PRIO_PROCESS) + { + set_errno(EINVAL); + return ERROR; + } + if (who == 0) { who = getpid();