sched_getaffinity() shall retrieve the affinity mask of a process.
The parameter pid specifies the ID for the process. If pid is 0, then the calling process is specified instead.
The parameter cpusetsize specifies the length of the data pointed to by mask, in bytes. Normally, this parameter is specified as sizeof(cpu_set_t).
On success, sched_getaffinity() shall return 0, and the structure pointed to by mask shall contain the affinity mask of the specified process.
On failure, sched_getaffinity()
shall return -1 and
errno as follows.
mask does not specify any processors that exist in the system, or cpusetsize is smaller than the kernel's affinity mask.
The specified process could not be found.