Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 201826 - Calls to nice(2) will fail with errno set to EACCES rather than EPERM
Calls to nice(2) will fail with errno set to EACCES rather than EPERM
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2006-08-09 00:02 EDT by William Kucharski
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 2.4.90-20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-08-15 10:19:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description William Kucharski 2006-08-09 00:02:00 EDT
Description of problem:

The man page for nice(2) states:

       EPERM  The  calling  process attempted to increase its priority by sup-
              plying a negative inc but has  insufficient  privileges.   Under
              Linux  the  CAP_SYS_NICE  capability  is required.  (But see the
              discussion of the RLIMIT_NICE resource limit in setrlimit(2).)

However, glibc() converts a call to nice(2) into a call to setpriority(2)
which WILL return with errno set to EACCES.

An strace of the program:

#include <errno.h>

        if (nice(-19) < 0)
                printf("%d\n", errno);

shows it in reality calls:

setpriority(PRIO_PROCESS, 0, 4294967277) = -1 EACCES (Permission denied)

Version-Release number of selected component (if applicable):


How reproducible:

Run the test program above.

Steps to Reproduce:
1. Compile the code snippet above
2. Run
3. See incorrect errno set
Actual results:

failure with errno set to EACCES

Expected results:

failure with errno set to EPERM

Additional info:

This isn't just a man page error, as if the legacy nice syscall is invoked,
it reacts as documented.

For example, this program:

#include <sys/types.h>
#include <sys/syscall.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

        if (nice(-19) < 0)
                printf("%d\n", errno);

        if (syscall(__NR_nice, -19) < 0)
                printf("%d\n", errno);

will return:

$ ./a.out
Comment 1 Jakub Jelinek 2006-08-15 10:19:45 EDT
Fixed in upstream CVS and glibc-2.4.90-20 in rawhide.

Note You need to log in before you can comment on or make changes to this bug.