What are the differences between spawning processes and inheriting application processes in PHP?

Spawning processes involves creating a new process that runs concurrently with the parent process, allowing for parallel execution. Inheriting application processes involves creating a new process that inherits the environment and state of the parent process, allowing for communication and sharing of resources.

// Spawning a new process
$pid = pcntl_fork();
if ($pid == -1) {
    die('Could not fork');
} else if ($pid) {
    // Parent process
    pcntl_wait($status); // Wait for the child process to finish
} else {
    // Child process
    // Code to be executed in the child process
}

// Inheriting application processes
$descriptorspec = array(
   0 => STDIN,
   1 => STDOUT,
   2 => STDERR
);
$process = proc_open('php child_process.php', $descriptorspec, $pipes);
if (is_resource($process)) {
    // Code to communicate with the child process
    proc_close($process);
}