Details

[Home]

Issue of the Standard # S0504

Brief

Function sched_setscheduler() always returns 0, but not the former scheduling policy

Detailed Description

According to LSB 3.1, upon successful completion, the sched_setscheduler() function shall return the former scheduling policy of the specified process.
But in the following code the result of the function is always 0 (run this code with root priviledges).
This behaviour doesn't contradict man pages.

#include <stdio.h> #include <sched.h> #include <unistd.h> #include <errno.h> int main(int argc, char* argv[]) { struct sched_param param; int res; param.sched_priority=3; res=sched_setscheduler(getpid(), SCHED_FIFO , ¶m); printf("res: %d, errno %d\n", res, errno); res=sched_setscheduler(getpid(), SCHED_RR, ¶m); printf("res: %d, errno %d\n", res, errno); res=sched_setscheduler(getpid(), SCHED_FIFO , ¶m); printf("res: %d, errno %d\n", res, errno); return 0; }

Problem location(s) in the standard

Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.5. Interface Definitions for libc, description of sched_setscheduler() interface.

Possible solutions

Correction of LSB standard

Accepted

LSB Bugzilla, 1661

Status

Fixed in LSB 3.1 Update 1

[Home]