OpenBSD manual page server

Manual Page Search Parameters

NICE(3) Library Functions Manual NICE(3)

nicechange process scheduling priority

#include <unistd.h>

int
nice(int incr);

This interface is obsoleted by setpriority(2).

The nice() function adds the value specified in incr to the scheduling priority of the invoking process.

incr is an integer such that the resulting scheduling priority is within the range -20 to 20. Priority values outside this range are truncated to the appropriate limit. The default priority is 0; lower priorities cause more favorable scheduling. Only the superuser may lower priorities.

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

On success, nice() returns the new priority. On error, it returns -1.

Since nice() can legitimately return the value -1, it is necessary to clear the external variable errno prior to the call, then check it afterward to determine if a -1 is an error or a legitimate value.

nice() has the same failure conditions as setpriority(2).

nice(1), fork(2), setpriority(2), renice(8)

A nice() system call first appeared in Version 3 AT&T UNIX. It has accepted an incr argument since Version 4 AT&T UNIX.

July 18, 2013 OpenBSD-current