Michael Dale wrote:
For the TimedMediaHandler I was adding more fine grain
control over
background processes [1] and ran into a unix issue around getting both a
pid and exit status for a given background shell command.
Essentially with a background task I can get the pid or the exit status
but can't seem to get both:
Do you want the command to be run asynchronously or not?
If you expect the status code to be returned by wfShellExec(), then the
process will obviously have finished and there's no need for the PID.
OTOH if you launch it as a background task, you will want to get the
PID, and then call pcntl_waitpid* on it to get the status code.
*pcntl_waitpid() may not work, because $cmd is unlikely to be a direct
children of php. You could also be expecting to check it from a
different request. So you would enter into the world of killing -0 the
process to check if it's still alive.