[patch] nice.2: wfix
Jakub Wilk
jwilk@jwilk.net
Wed Dec 14 15:28:40 GMT 2022
* Alejandro Colomar <alx.manpages@gmail.com>, 2022-12-11 18:33:
>>-to the nice value for the calling thread.
>>+to the nice value for the calling process.
nice() affecting the whole process, not just the calling thread, is what
POSIX requires, and what glibc documents, but it's not actually how it
works on Linux at the moment[*].
This is documented in the setpriority(2) man page:
"According to POSIX, the nice value is a per-process setting. However,
under the current Linux/NPTL implementation of POSIX threads, the nice
value is a per-thread attribute: different threads in the same process
can have different nice values. Portable applications should avoid
relying on the Linux behavior, which may be made standards conformant in
the future."
It would be prudent to document this bug in the nice(2) man page too.
[*] I've tested this with Linux 6.0 + glibc 2.36.
See the attached test program.
--
Jakub Wilk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-nice.c
Type: text/x-csrc
Size: 563 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20221214/ca058018/attachment.bin>
More information about the Libc-alpha
mailing list