note 70135 deleted from ref.exec by crell

From: Date: Thu, 31 Mar 2022 20:58:43 +0000
Subject: note 70135 deleted from ref.exec by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217994@lists.php.net to get a copy of this message
Note Submitter: PHP at jyoppDot-com ---- Here's a function to launch a low-priority background process very simply, returning control to the foreground. I found that a lot of the other approaches shown here allow the script to continue running, and the page is served up to the user, but the PHP thread that launched the process cannot be re-used until the process has completed. Stdout and stderr need to be redirected to /dev/null to prevent this. This is for BSD/*NIX servers only (tested on Fedora Core and OSX). Win32 approaches would be necessarily very different. Omit 'nice' if you don't want to run the process with lowered priority. <?php function fork($shellCmd) { exec("nice $shellCmd > /dev/null 2>&1 &"); } ?>

« previous php.notes (#217994) next »