mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
sched_getaffinity(3): more compatibility with Linux
Report EINVAL instead of EDEADLK when impossible cpu mask is set. Noted by: dchagin Reviewed by: dchagin (previous version), markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35045
This commit is contained in:
parent
0a736f0a6a
commit
67fc95025c
1 changed files with 7 additions and 2 deletions
|
|
@ -34,6 +34,7 @@ int
|
|||
sched_setaffinity(pid_t pid, size_t cpusetsz, const cpuset_t *cpuset)
|
||||
{
|
||||
cpuset_t c;
|
||||
int error;
|
||||
|
||||
if (cpusetsz > sizeof(cpuset_t)) {
|
||||
errno = EINVAL;
|
||||
|
|
@ -42,6 +43,10 @@ sched_setaffinity(pid_t pid, size_t cpusetsz, const cpuset_t *cpuset)
|
|||
memset(&c, 0, sizeof(c));
|
||||
memcpy(&c, cpuset, cpusetsz);
|
||||
}
|
||||
return (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
|
||||
pid == 0 ? -1 : pid, sizeof(cpuset_t), &c));
|
||||
error = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
|
||||
pid == 0 ? -1 : pid, sizeof(cpuset_t), &c);
|
||||
if (error == -1 && errno == EDEADLK)
|
||||
errno = EINVAL;
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue