NICE(3POSIX)
π NICE(3POSIX) π
okay bestie, so this is NICE(3POSIX) from the POSIX Programmer's Manual β the Linux version of this interface might be different (peep the matching Linux man page for the deets on Linux behavior), or honestly it might not even be implemented on Linux at all. π
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
β¨ NAME β¨
nice β change the nice value of a process π
π¦ SYNOPSIS π¦
#include <unistd.h>
int nice(int incr);
π DESCRIPTION π
So the nice() function shall add the value of incr to the nice value of the calling process. And a nice value of a process is a non-negative number where a more positive value shall result in less favorable scheduling. It's giving "be nice, get less CPU" β the math is mathing. π
A maximum nice value of 2*{NZERO}-1 and a minimum nice value of 0 shall be imposed by the system. Requests for values above or below these limits shall result in the nice value being set to the corresponding limit. Only a process with appropriate privileges can lower the nice value. π
Calling the nice() function has no effect on the priority of processes or threads with policy SCHED_FIFO or SCHED_RR. The effect on processes or threads with other scheduling policies is implementation-defined.
The nice value set with nice() shall be applied to the process. If the process is multi-threaded, the nice value shall affect all system scope threads in the process. everyone's getting the vibe check, no exceptions π«Ά
β οΈ okay this part is important bestie: as-1is a permissible return value in a successful situation, an application wishing to check for error situations should seterrnoto0, then callnice(), and if it returns-1, check to see whethererrnois non-zero. it's giving "you can't trust a single -1, you have to double check" π
π RETURN VALUE π
Upon successful completion, nice() shall return the new nice value -{NZERO}. Otherwise, -1 shall be returned, the nice value of the process shall not be changed, and errno shall be set to indicate the error. no half-sends, no accidental edits, we love a clean fail π₯
π ERRORS π
The nice() function shall fail if:
EPERMβ Theincrargument is negative and the calling process does not have appropriate privileges.
The following sections are informative.
π EXAMPLES π
Changing the Nice Value
The following example adds the value of the incr argument, -20, to the nice value of the calling process.
#include <unistd.h>
...
int incr = -20;
int ret;
ret = nice(incr);
π APPLICATION USAGE π
None.
β RATIONALE β
None.
π§ FUTURE DIRECTIONS π§
None.
π₯ SEE ALSO π₯
exec,getpriority()- The Base Definitions volume of POSIX.1β2017,
<limits.h>,<unistd.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie β brought to you by IEEE/The Open Group, 2017, under the NICE(3POSIX) name. go forth and schedule responsibly β¨π
π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms