pcntl_getpriority

(PHP 5, PHP 7, PHP 8)

pcntl_getpriorityプロセスの優先度を取得する

説明

pcntl_getpriority(int $pid = getmypid(), int $process_identifier = PRIO_PROCESS): int

pcntl_getpriority() は、pid の優先度を設定します。システムの型やカーネルの バージョンによって優先度の扱いは違うので、詳細についてはシステムの getpriority(2) の man ページを参照ください。

パラメータ

pid

指定しなかった場合は、現在のプロセスの PID を使用します。

process_identifier

PRIO_PGRPPRIO_USER あるいは PRIO_PROCESS のいずれか。

返り値

pcntl_getpriority() はプロセスの優先度を返します。 エラー時には false を返します。数字が小さいほど、優先順位は上となります。

警告

この関数は論理値 false を返す可能性がありますが、false として評価される値を返す可能性もあります。 詳細については 論理値の セクションを参照してください。この関数の返り値を調べるには ===演算子 を 使用してください。

参考

add a note add a note

User Contributed Notes 1 note

up
1
jonathan at jcdesigns dot com
16 years ago
This function is ideal for checking if a given process is running, I have seen solutions that involve running the system utilites like PS and parsing the answer, which should work fine, but this allows you to check a given PID with a single call

function CheckPID( $PID )
{
        // Check if the passed in PID represents a vlaid process in the system
        // Returns true if it does
        // Turn off non-fatal runtime warning for a moment as we know we
        // will get one if the PID does not represent a valid process

    $oldErrorLevel = error_reporting(0);
    error_reporting( $oldErrorLevel & ~E_WARNING );
    $res = pcntl_getpriority($PID);
    error_reporting( $oldErrorLevel);
    return ! ( $res === false);
}
To Top