Perl setpriority Function



This function sets the priority for a process (PRIO_PROCESS), process group (PRIO_PGRP), or user (PRIO_USER). The argument WHICH specifies what entity to set the priority for, and WHO is the process ID or user ID to set. A value of 0 for WHO defines the current process, process group, or user. Produces a fatal error on systems that don.t support the system setpriority( ) function.

The priority is a number representing the level of priority (normally in the range 120 to 20) where the lower the priority the more favorable the scheduling of the process by the operating system.


Following is the simple syntax for this function −

setpriority WHICH, WHO, PRIORITY

Return Value

This function does not return any value.


Following is the example code showing its basic usage −


print("setpriority() ", setpriority(0, 0, -20), "\n");

When above code is executed, it produces the following result −

setpriority() 0