Discussion:
sched_setscheduler returns EPERM instead of EINVAL when sched_priority is out of range
Ali Abdallah
2018-04-20 12:08:55 UTC
Permalink
Hello,

I got quite confused when I was getting EPERM from the sched_setscheduler
system call on FreeBSD 11.1, thinking at the beginning that I had a
permission problem (program uses setuid, and it is launched by normal
user). After, I realized that my sched_param.sched_priority value was
simply out of range.

According to the documentation, [EINVAL] should be returned if the value of
the policy argument is invalid, or one or more parameters contained in
param is outside the valid range!

In ksched.c line 180, the ksched_setscheduler functions returns EPERM when
(param->sched_priority >= P1B_PRIO_MIN && param->sched_priority <=
P1B_PRIO_MAX), on other Unices, I get EINVAL as expected.

Is there is a reason for why FreeBSS handles this differently?

Cheers,
Ali

Loading...