NICE(3)
πΈ NICE(3) β the vibe check πΈ
hey bestie, welcome to NICE(3) from the Library Functions Manual β yes, the manual name is literally in the header and we're folding it in right at the top so you don't miss it. this page is all about setting program scheduling priority, and honestly it's giving vintage Unix lore. let's get into it π
β¨ NAME β¨
nice β set program scheduling priority
like, that's the whole assignment. set program scheduling priority, periodt.
π LIBRARY π
Standard C Library (libc, -lc)
she lives in libc, no cap. link with -lc and you're good π«Ά
π§ SYNOPSIS π§
#include <unistd.h>
int
nice(int incr);
look at that signature. iconic. int nice(int incr); β that's the whole call, bestie.
π DESCRIPTION π
okay so first thing you need to know: this interface is obsoleted by setpriority(2). like, not me reading that and gasping β it's literally in the description. so yes, nice() is lowkey legacy, but we still respect the lore π
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. only the super-user may lower priorities β that's the rule, don't forget it π
children inherit the priority of their parent processes via fork(2). so yeah, the vibes are inherited. generational scheduling priority, iykyk π§¬
π₯ 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.
so like, success is 0, failure is -1, and errno tells you what went wrong. no surprises, just facts β¨
π ERRORS π
the nice() function will fail if:
[EPERM]β theincrargument is negative and the caller does not have appropriate privileges.
that's it. that's the error list. dramatic pause for EPERM π
π SEE ALSO π
go read those too, bestie. the whole friend group is linked π«Ά
π 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.
so yeah, this implementation is a little different from the standard on the return value β and that's important. the standard wants the new nice value back; this one gives you 0 on success. and since the new nice value could be -1, that's extra spicy. noted π
π¦ HISTORY π¦
a nice() syscall appeared in Version 6 AT&T UNIX.
old money. vintage. Version 6 AT&T UNIX β we love a historical icon π
mwah π this page was brought to you by Debian, dated February 28, 2015, and the manual name is NICE(3). slay and read your man pages, bestie π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms