This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Solaris: Fix error checking in sched_get_priority_ functions
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jstasiak, kulikjak
Priority: normal Keywords: patch

Created on 2020-09-23 09:44 by kulikjak, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 22374 open kulikjak, 2020-09-23 09:46
Messages (3)
msg377363 - (view) Author: Jakub Kulik (kulikjak) * Date: 2020-09-23 09:44
Python presumes that any negative number returned from sched_get_priority_min or sched_get_priority_max indicates that error has occurred. However, neither Linux manual pages nor POSIX.1-2001 specification forbids negative values to be returned; only -1 has a special meaning for error.

On Solaris, sched_get_priority_min can, in some instances, return -60, and while this is a legitimate scheduling priority value, Python throws an OSError. Checking for -1 rather than all negative values fixes this issue.
msg380418 - (view) Author: Jakub Stasiak (jstasiak) * Date: 2020-11-05 16:42
I think negative values aren't possible on Linux if one's to trust the sched_get_priority_min man page:


       Linux allows the static priority range 1 to 99 for the SCHED_FIFO and
       SCHED_RR policies, and the priority 0 for the remaining policies.
       Scheduling priority ranges for the various policies are not
       alterable.

But yeah, it seems that negative values need to be accepted on Solaris.
msg380451 - (view) Author: Jakub Kulik (kulikjak) * Date: 2020-11-06 15:49
> Checking for -1 rather than all negative values fixes this issue.

To be 100% exact, it should be "checking for -1 and errno" (as other Jakub noted in the PR). Here is the standard for reference:
https://pubs.opengroup.org/onlinepubs/009695399/functions/sched_get_priority_min.html

Sticking to it should hopefully not break anything.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 86005
2020-11-06 15:49:23kulikjaksetmessages: + msg380451
2020-11-05 16:42:34jstasiaksetnosy: + jstasiak
messages: + msg380418
2020-10-30 13:35:05vstinnersettitle: Fix error checking in sched_get_priority_ functions -> Solaris: Fix error checking in sched_get_priority_ functions
2020-09-23 10:04:20kulikjaksetversions: + Python 3.8
2020-09-23 09:46:39kulikjaksetkeywords: + patch
stage: patch review
pull_requests: + pull_request21413
2020-09-23 09:44:51kulikjakcreate