nice(2)

โœจ nice(2) โ€” the manual, but make it cute โœจ

okay bestie, so this is nice(2), a system call from the Linux man-pages situation ๐Ÿ’– it lives in the System Calls Manual section and it's literally about changing your process priority. yes, the function is called nice. yes, that's adorable. let's go ๐Ÿฆ‹


๐Ÿ’ซ NAME ๐Ÿ’ซ

nice โ€” change process priority

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc)

๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <unistd.h>

int nice(int inc);

๐ŸŽ€ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): ๐ŸŽ€

nice():

_XOPEN_SOURCE
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

๐Ÿ‘‘ DESCRIPTION ๐Ÿ‘‘

So nice() adds inc to the nice value for the calling thread. and before you ask โ€” yeah, a higher nice value means a lower priority. it's giving "be nice, get less attention" ๐Ÿ˜ญ iconic behaviour ngl.

The range of the nice value is +19 (low priority) all the way to -20 (high priority). if you try to set a nice value outside that range? it gets clamped to the range. no error, no drama, just vibes ๐Ÿ’…

Traditionally, only a privileged process could lower the nice value (i.e., set a higher priority). BUT โ€” plot twist โ€” since Linux 2.6.12, an unprivileged process can decrease the nice value of a target process that has a suitable RLIMIT_NICE soft limit. see getrlimit(2) for the details, bestie, i'm not gatekeeping but the manpage is right there ๐Ÿซถ

๐Ÿ”ฅ RETURN VALUE ๐Ÿ”ฅ

On success, the new nice value is returned (but see VERSIONS below, because it's messy ๐Ÿ‘€). On error, -1 is returned, and errno is set to indicate the error.

WARNING bestie this is the trickiest part!! a successful call can legitimately return -1. no i'm serious. so to actually detect an error, you gotta set errno to 0 before the call, and then check whether it's nonzero after nice() returns -1. do not skip this step. it will humble you ๐Ÿ’€

๐Ÿ˜ญ ERRORS ๐Ÿ˜ญ

  • EPERM โ€” The calling process attempted to increase its priority by supplying 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).) so basically: you tried to be too main character and the kernel said no ๐Ÿ™ˆ

๐ŸŒˆ VERSIONS ๐ŸŒˆ

๐Ÿงš C library/kernel differences ๐Ÿงš

POSIX.1 specifies that nice() should return the new nice value. However, the raw Linux system call returns 0 on success. Likewise, the nice() wrapper function provided in glibc 2.2.3 and earlier returns 0 on success. so yeah. history was messy โœจ

Since glibc 2.2.4, the nice() wrapper function provided by glibc provides conformance to POSIX.1 by calling getpriority(2) to obtain the new nice value, which is then returned to the caller. she got her act together ๐Ÿ’…

โญ STANDARDS โญ

POSIX.1-2024.

๐Ÿฆ‹ HISTORY ๐Ÿฆ‹

POSIX.1-2001, SVr4, 4.3BSD. ancient. legendary. built different fr fr.

๐Ÿ’œ NOTES ๐Ÿ’œ

For further details on the nice value, see sched(7).

Note: the addition of the "autogroup" feature in Linux 2.6.38 means that the nice value no longer has its traditional effect in many circumstances. for details, see sched(7). yeah that's a real thing that changes real behaviour, not just lore, so go read it ๐Ÿ‘‘

๐ŸŒŸ SEE ALSO ๐ŸŒŸ


and that's the whole page bestie ๐ŸŽ€ this was Linux man-pages 6.20, dated 2026-02-08, and it's the nice(2) girlies' moment. go forth and schedule responsibly ๐Ÿ’–โœจ๐ŸŒธ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms