How can the bypass_shell parameter be utilized in proc_open to ensure the correct PID is displayed, especially on Linux systems?

When using proc_open in PHP on Linux systems, the bypass_shell parameter can be utilized to ensure the correct PID is displayed. By setting bypass_shell to true, the command is executed directly without going through a shell, which can sometimes alter the PID. This ensures that the PID displayed is the correct one for the process.

$descriptorspec = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "/tmp/error-output.txt", "a")
);

$process = proc_open('/path/to/command', $descriptorspec, $pipes, null, null, array('bypass_shell' => true));

if (is_resource($process)) {
    $status = proc_get_status($process);
    echo "PID: " . $status['pid'] . PHP_EOL;

    // Close the pipes and process
    fclose($pipes[0]);
    fclose($pipes[1]);
    proc_close($process);
}