PHP 8.4.24 Released!

Voting

: max(five, zero)?
(Example: nine)

The Note You're Voting On

jakster at gmx dot net
18 years ago
To fork a process I use the following code

<?php

fclose(STDOUT);   //Close all output or it WON'T work
fclose(STDIN);
fclose(STDERR);

if(pcntl_fork()) {
    exit;            //Return to the caller
}

//Code to run in the background

pcntl_exec("/usr/bin/php",Array($_SERVER['argv'][1]));

?>

I call this script from my website with
<?php 
function fork($script){        //run a forked php script relative to the document root. NO OUTPUT IS DISPLAYED!
    global $config;
    $cmd = "/usr/bin/php \"" . dirname($_SERVER['SCRIPT_FILENAME']) . "/includes/forked/forkHelper.php\" \"" . $script . "\"";
    exec($cmd);
}
?>

<< Back to user notes page

To Top