On 06/14/2011 05:41 PM, Platonides wrote:
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.
Yes the idea is to run the command asynchronously so we can monitor the transcode progress and kill it if it stops making progress.
Calling pcntl_waitpid with pcntl_fork as Tim mentions may be the way to get it done. With the child including the pcntl_waitpid call and the parent monitoring "progress" and killing the child if need be.
--michael