nice(3)

nice3

Set program scheduling priority

Usage

#include <unistd.h>

int

nice(int incr);

Library

Standard C Library (libc, -lc)

Overview

This interface is obsoleted by setpriority(2).

The nice() function adds incr to the scheduling priority of the process. The priority is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. Only the super-user may lower priorities.

Children inherit the priority of their parent processes via fork(2).

Return values

Upon successful completion, nice() returns 0, and errno is unchanged. Otherwise, -1 is returned, the process' nice value is not changed, and errno is set to indicate the error.

Errors

The nice() function will fail if:

[EPERM]

The incr argument is negative and the caller does not have appropriate privileges.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 42 times.

  1. 2.0.5–2.1.7.1
  2. 2.2.2–2.2.5
  3. 2.2.6–3.4
  4. 3.5–3.5.1
  5. 4.0
  6. 4.1–4.2
  7. 4.3
  8. 4.4
  9. 4.5–4.11
  10. 5.0–6.3
  11. 6.4
  12. 7.0
  13. 7.1
  14. 7.2
  15. 7.3
  16. 7.4
  17. 8.0
  18. 8.1
  19. 8.2
  20. 8.3
  21. 8.4
  22. 9.0
  23. 9.1
  24. 9.2
  25. 9.3
  26. 10.0
  27. 10.1
  28. 10.2
  29. 10.3
  30. 10.4
  31. 11.0
  32. 11.1
  33. 11.2
  34. 11.3
  35. 11.4
  36. 12.0
  37. 12.1
  38. 12.2
  39. 12.3
  40. 12.4
  41. 13.0–13.2
  42. 13.3–14.5
  43. 15.0–16.0

Standards

The nice() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”) except for the return value. This implementation returns 0 upon successful completion but the standard requires returning the new nice value, which could be -1.

History

A nice() syscall appeared in Version 6 AT&T UNIX.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.