exec () is a great function to use, but you will have to wait until the process completes to continue working with the parent script. If you are running a process package where each process takes a little time, I would suggest using popen ().
The variable you get creates a pointer to the channel, which allows you to go through several processes at a time, saving them in an array, and then getting them all at a consistent speed after everything is ready (much more at the same time) using steam_get_contents ( )
This is especially useful if you are calling API calls or running scripts that may not be memory intensive or computationally intensive, but require a significant wait for each of them to complete.
Robert Elwell
source share