If you have an extension, use the PCNTL functions. They abstract you from obtaining process identifiers, checking their status, etc.
pcntl_execto start the processpcntl_waitpidwith an option WNOHANGto poll your current state.- ,
> /tmp/somefile 2>&1 . - tempnam()