Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

pcntl_getpriority

Description

The pcntl_getpriority of PCNTL for PHP gets the priority of any process.

Syntax

pcntl_getpriority(
    ?int $process_id = null,
    int $mode = PRIO_PROCESS
): int|false

Parameters

process_id

If null, the process id of the current process is used.

mode

One of PRIO_PGRP, PRIO_USER, PRIO_PROCESS, PRIO_DARWIN_BG or PRIO_DARWIN_THREAD.

Return

Returns the priority of the process or false on error. A lower numerical value causes more favorable scheduling.

WARNING: This function may return Boolean false, but may also return a non-Boolean value which evaluates to false. Use the === operator for testing the return value of this function.

Examples

1 · void

<?

$return = pcntl_getpriority();

if($return === false)
{
    die("pcntl_getpriority");
}

var_export($return);

?>
0

2 · process_id

<?

$process_id = posix_getpid();

$return = pcntl_getpriority($process_id);

if($return === false)
{
    die("pcntl_getpriority");
}

var_export($return);

?>
0

3 · mode · PRIO_PGRP

<?

$process_id = posix_getpgrp();
$mode = PRIO_PGRP;

$return = pcntl_getpriority($process_id, $mode);

if($return === false)
{
    die("pcntl_getpriority");
}

var_export($return);

?>
0

4 · mode · PRIO_USER

<?

$process_id = posix_getuid();
$mode = PRIO_USER;

$return = pcntl_getpriority($process_id, $mode);

if($return === false)
{
    die("pcntl_getpriority");
}

var_export($return);

?>
0

5 · mode · PRIO_PROCESS

<?

$process_id = posix_getpid();
$mode = PRIO_PROCESS;

$return = pcntl_getpriority($process_id, $mode);

if($return === false)
{
    die("pcntl_getpriority");
}

var_export($return);

?>
0
HomeMenu