proc_get_status example


    protected function updateStatus(bool $blocking)
    {
        if (self::STATUS_STARTED !== $this->status) {
            return;
        }

        $this->processInformation = proc_get_status($this->process);
        $running = $this->processInformation['running'];

        $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);

        if ($this->fallbackStatus && $this->isSigchildEnabled()) {
            $this->processInformation = $this->fallbackStatus + $this->processInformation;
        }

        if (!$running) {
            $this->close();
        }
    }
$list = dba_list();
        $a['file'] = $list[(int) $dba];

        return $a;
    }

    /** * @return array */
    public static function castProcess($process, array $a, Stub $stub, bool $isNested)
    {
        return proc_get_status($process);
    }

    public static function castStream($stream, array $a, Stub $stub, bool $isNested): array
    {
        $a = stream_get_meta_data($stream) + static::castStreamContext($stream$a$stub$isNested);
        if ($a['uri'] ?? false) {
            $a['uri'] = new LinkStub($a['uri']);
        }

        return $a;
    }

    
    $descriptors = [];
    $descriptors[0] = STDIN;
    $descriptors[1] = ['pipe', 'w'];
    $descriptors[2] = ['pipe', 'w'];
    $server = proc_open($process->getCommandLine()$descriptors$pipes$kernel->getAppRoot());
    if (is_resource($server)) {
      if ($io->isVerbose()) {
        // Write a blank line so that server output and the useful information are         // visually separated.         $io->writeln('');
      }
      $server_status = proc_get_status($server);
      while ($server_status['running']) {
        if ($io->isVerbose()) {
          fpassthru($pipes[2]);
        }
        sleep(1);
        $server_status = proc_get_status($server);
      }
    }
    return proc_close($server);
  }

  
echo "\033[41mKO\033[0m $component\n\n";
        }
    }

    $lastOutput = null;
    $lastOutputTime = null;

    while ($runningProcs) {
        usleep(300000);
        $terminatedProcs = [];
        foreach ($runningProcs as $component => $proc) {
            $procStatus = proc_get_status($proc);
            if (!$procStatus['running']) {
                $terminatedProcs[$component] = $procStatus['exitcode'];
                unset($runningProcs[$component]);
                proc_close($proc);
            }
        }

        if (!$terminatedProcs && 1 === count($runningProcs)) {
            $component = key($runningProcs);

            $output = file_get_contents("$component/phpunit.stdout");
            
        // another byte which will never be read.         $expectedOutputSize = PipesInterface::CHUNK_SIZE * 2 + 2;

        $code = sprintf('echo str_repeat(\'*\', %d);', $expectedOutputSize);
        $p = $this->getProcessForCode($code);

        $p->start();

        // Don't call Process::run nor Process::wait to avoid any read of pipes         $h = new \ReflectionProperty($p, 'process');
        $h = $h->getValue($p);
        $s = @proc_get_status($h);

        while (!empty($s['running'])) {
            usleep(1000);
            $s = proc_get_status($h);
        }

        $o = $p->getOutput();

        $this->assertEquals($expectedOutputSize, \strlen($o));
    }

    
$list = dba_list();
        $a['file'] = $list[(int) $dba];

        return $a;
    }

    /** * @return array */
    public static function castProcess($process, array $a, Stub $stub, bool $isNested)
    {
        return proc_get_status($process);
    }

    public static function castStream($stream, array $a, Stub $stub, bool $isNested): array
    {
        $a = stream_get_meta_data($stream) + static::castStreamContext($stream$a$stub$isNested);
        if ($a['uri'] ?? false) {
            $a['uri'] = new LinkStub($a['uri']);
        }

        return $a;
    }

    

    protected function updateStatus(bool $blocking)
    {
        if (self::STATUS_STARTED !== $this->status) {
            return;
        }

        $this->processInformation = proc_get_status($this->process);
        $running = $this->processInformation['running'];

        $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);

        if ($this->fallbackStatus && $this->isSigchildEnabled()) {
            $this->processInformation = $this->fallbackStatus + $this->processInformation;
        }

        if (!$running) {
            $this->close();
        }
    }
Home | Imprint | This part of the site doesn't use cookies.