'PHP spawn background process with a specific process ID range
I'm working on a PHP function that spawns PHP background processes that do something, the issue I'm facing is that my script is potentially picking a process ID that's already being used on the system, my function, shell_exec needs to pick from a range, so for example, only pick a process ID between 3000 - 4000, meaning a possible 1000 different process IDs that it can choose from, how can I achieve this with my current function:
// trigger the process
$bgProcessID = shell_exec(sprintf(
'%s > %s 2>&1 & echo $!', $this->getQueueProcessCommand($jobID), '/dev/null'
));
For reference, but unrelated, getQueueProcessCommand is:
protected function getQueueProcessCommand($job)
{
$appDir = rtrim(APP, '/');
return "$appDir/Console/cake queue_manager process --job=$job";
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
