[Process] Add more precision to Process::stop timeout

This commit is contained in:
Romain Neutron 2013-08-13 19:23:51 +02:00
parent 57d4159133
commit fa769a2c21
1 changed files with 2 additions and 4 deletions

View File

@ -631,12 +631,10 @@ class Process
*/
public function stop($timeout = 10)
{
$timeoutMicro = (int) $timeout*1E6;
$timeoutMicro = microtime(true) + $timeout;
if ($this->isRunning()) {
proc_terminate($this->process);
$time = 0;
while (1 == $this->isRunning() && $time < $timeoutMicro) {
$time += 1000;
while ($this->isRunning() && microtime(true) < $timeoutMicro) {
usleep(1000);
}