NICE(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

🌸 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] β€” the incr argument 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms