Symfony\Component\Process\Process::isRunning PHP Method

isRunning() public method

Checks if the process is currently running.
public isRunning ( ) : boolean
return boolean true if the process is currently running, false otherwise
    public function isRunning()
    {
        if (self::STATUS_STARTED !== $this->status) {
            return false;
        }
        $this->updateStatus(false);
        return $this->processInformation['running'];
    }

Usage Example

Example #1
0
 public function testControlledExit()
 {
     if (!extension_loaded('pcntl')) {
         $this->markTestSkipped('PCNTL extension is not loaded.');
     }
     $proc = new Process('exec ' . PHP_BINARY . ' ' . escapeshellarg(__DIR__ . '/console') . ' jms-job-queue:run --worker-name=test --verbose --max-runtime=999999');
     $proc->start();
     usleep(500000.0);
     $this->assertTrue($proc->isRunning(), 'Process exited prematurely: ' . $proc->getOutput() . $proc->getErrorOutput());
     $this->assertTrueWithin(3, function () use($proc) {
         return false !== strpos($proc->getOutput(), 'Signal Handlers have been installed');
     }, function () use($proc) {
         $this->fail('Signal handlers were not installed: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $proc->signal(SIGTERM);
     $this->assertTrueWithin(3, function () use($proc) {
         return false !== strpos($proc->getOutput(), 'Received SIGTERM');
     }, function () use($proc) {
         $this->fail('Signal was not received by process within 3 seconds: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $this->assertTrueWithin(3, function () use($proc) {
         return !$proc->isRunning();
     }, function () use($proc) {
         $this->fail('Process did not terminate within 3 seconds: ' . $proc->getOutput() . $proc->getErrorOutput());
     });
     $this->assertContains('All jobs finished, exiting.', $proc->getOutput());
 }
All Usage Examples Of Symfony\Component\Process\Process::isRunning